Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 5962d8d

Browse files
committed
Make Jenkins use npmrc configuration file.
Remove npm-cli-login dependency for Jenkins publishes.
1 parent ab2e1be commit 5962d8d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Jenkinsfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!groovy
2-
// Copyright © 2017 IBM Corp. All rights reserved.
2+
// Copyright © 2017, 2019 IBM Corp. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -101,16 +101,14 @@ stage('Publish') {
101101

102102
// Upload using the NPM creds
103103
withCredentials([string(credentialsId: 'npm-mail', variable: 'NPM_EMAIL'),
104-
usernamePassword(credentialsId: 'npm-creds', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
104+
usernamePassword(credentialsId: 'npm-creds', passwordVariable: 'NPM_TOKEN', usernameVariable: 'NPM_USER')]) {
105105
// Actions:
106-
// 1. add the build ID to any snapshot version for uniqueness
107-
// 2. install login helper
108-
// 3. login to npm, using environment variables specified above
109-
// 4. publish the build to NPM adding a snapshot tag if pre-release
106+
// 1. create .npmrc file for publishing
107+
// 2. add the build ID to any snapshot version for uniqueness
108+
// 3. publish the build to NPM adding a snapshot tag if pre-release
110109
sh """
110+
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
111111
${isReleaseVersion ? '' : ('npm version --no-git-tag-version ' + version + '.' + env.BUILD_ID)}
112-
npm install --no-save npm-cli-login
113-
./node_modules/.bin/npm-cli-login
114112
npm publish ${isReleaseVersion ? '' : '--tag snapshot'}
115113
"""
116114
}

0 commit comments

Comments
 (0)