Skip to content

Commit a75d7d9

Browse files
committed
Changed .npmrc to use credential token
Signed-off-by: Jeonghyuk Park <[email protected]>
1 parent 9d402ee commit a75d7d9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Jenkinsfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def TEST_NPM_REGISTRY = "https://eu.artifactory.swg-devops.com/artifactory/api/n
4141
/**
4242
* npm registry
4343
*/
44-
def NPM_REGISTRY = "https://registry.npmjs.org/"
44+
def NPM_REGISTRY = "registry.npmjs.org"
45+
def NPM_FULL_REGISTRY = "https://registry.npmjs.org"
4546

4647
/**
4748
* The root results folder for items configurable by environmental variables
@@ -144,6 +145,8 @@ pipeline {
144145
PATH = "${NPM_CONFIG_PREFIX}/bin:${PATH}"
145146

146147
// Credential to publish to npmjs.org
148+
// NPM_CREDENTIALS_USR is email address
149+
// NPM_REDENTIALS_PSW is the login token
147150
NPM_CREDENTIALS = credentials('ibmcics.npmjs.auth.token')
148151
}
149152

@@ -516,7 +519,7 @@ pipeline {
516519
echo "NEW_VERSION: ${NEW_VERSION}"
517520
// Retrieve released version from npmjs.org
518521
def RELEASED_VERSION = sh (
519-
script: 'npm view "$(echo "console.log(require(\'./package.json\').name);" | node)" version --registry '+NPM_REGISTRY+' || true',
522+
script: 'npm view "$(echo "console.log(require(\'./package.json\').name);" | node)" version --registry '+NPM_FULL_REGISTRY+' || true',
520523
returnStdout: true
521524
).trim()
522525
echo "RELEASED_VERSION: ${RELEASED_VERSION}"
@@ -580,12 +583,12 @@ pipeline {
580583
sh "echo @brightside:registry=https://api.bintray.com/npm/ca/brightside/ >> .npmrc"
581584
sh "echo @brightside:always-auth=false >> .npmrc"
582585
if (BRANCH_NAME == MASTER_BRANCH) {
583-
// Set credential
584-
sh "echo _auth=${NPM_CREDENTIALS} >> .npmrc"
585586
// Set registry
586-
sh "echo registry=$NPM_REGISTRY >> .npmrc"
587+
sh "echo registry=$NPM_FULL_REGISTRY >> .npmrc"
588+
// Set credential
589+
sh "echo //$NPM_REGISTRY/:_authToken=${NPM_CREDENTIALS_PSW} >> .npmrc"
587590
// deploy
588-
echo "publishing to $NPM_REGISTRY"
591+
echo "publishing to $NPM_FULL_REGISTRY"
589592
sh "npm publish --tag latest"
590593
} else if (BRANCH_NAME == DEV_BRANCH) {
591594
// Set version

0 commit comments

Comments
 (0)