Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ module.exports = function (grunt) {
packaging: 'zip',
auth: {
username: auth.username,
password: auth.password
password: auth.password,
headers: {
'Authorization': 'Bearer token123',
'Private-Token': 'secret-api-token'
}
},
pomDir: 'test/actual/releases',
url: 'http://localhost:8081/nexus/content/repositories/releases',
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ Default value: `''`

Username to be used for authentication against nexus server

#### options.auth.headers
Type: `Object`
Default value: `{}`

A key-value pair where each will be passed as Http Request Header to authenticate against nexus server.
E.g. Personal Access Token instead of username/password:
`{Authorization: 'Bearer secret-token'}`

#### options.insecure
Type: `boolean`
Default value: `false`
Expand Down Expand Up @@ -166,4 +174,4 @@ Whether to upload artifacts in parallel.
Type: `Boolean`
Default value: `'false'`

Chatty flag.
Chatty flag.
12 changes: 10 additions & 2 deletions tasks/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,16 @@ var createAndUploadArtifacts = function (options, done) {
curlOptions.push('/dev/stderr');
}
if (options.auth) {
curlOptions.push('-u');
curlOptions.push('"'+options.auth.username + ":" + options.auth.password+'"');
if (options.auth.username && options.auth.password) {
curlOptions.push('-u');
curlOptions.push('"' + options.auth.username + ":" + options.auth.password + '"');
}
if (options.auth.headers) {
Object.keys(options.auth.headers).map(function (key) {
curlOptions.push('--header');
curlOptions.push('"' + key + ': ' + options.auth.headers[key] + '"');
});
}
}

if (options.insecure) {
Expand Down