-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Basic Authentication (Issue #2) #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ export function getConnectionStatusName(status: ConnectionStatus): string { | |
export class Jenkins { | ||
|
||
|
||
public getStatus(url: string) { | ||
public getStatus(url: string, username: string, password: string) { | ||
|
||
return new Promise<JenkinsStatus>((resolve, reject) => { | ||
|
||
|
@@ -88,7 +88,12 @@ export class Jenkins { | |
let result: JenkinsStatus; | ||
|
||
request | ||
.get(url + '/api/json') | ||
.get(url + '/api/json', { | ||
'auth': { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should do more tests for this because I couldn't get this work that way. But It worked my way like a I wrote (see #3). It looks like it depends on the version of Jenkins people are using. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forget this. It works also on my side (idk why it didn't work the first time). it should be ok on every version I guess. But I've you tried it on the v1.647 but secured (it could have been some changes in the api between v1 and v2) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @umens Thanks for checking this out. I didn't test against 1.647 secured; that's a good idea. I will secure my 1.647 instance and test against it later this morning. I'll report back once I've done so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I secured my 1.647 instance and tested. All scenarios perform as expected, whether providing a password or a token. |
||
'user': username, | ||
'pass': password | ||
} | ||
}) | ||
.on('response', function(response) { | ||
statusCode = response.statusCode; | ||
}) | ||
|
@@ -111,9 +116,10 @@ export class Jenkins { | |
resolve(result); | ||
break; | ||
|
||
case 401: | ||
case 403: | ||
result = { | ||
jobName: 'AUTENTICATION NEEDED', | ||
jobName: 'AUTHENTICATION NEEDED', | ||
url: url, | ||
status: BuildStatus.Disabled, | ||
statusName: 'Disabled', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also specify that we can also use a token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed; I'll make the change. Something like
"jenkins_user"
and"jenkins_password_or_token"
seem reasonable?