fix: generate npm auth via PowerShell to bypass Jenkins Groovy sandbox
这个提交包含在:
父节点
987e4f5952
当前提交
191d742591
18
Jenkinsfile
vendored
18
Jenkinsfile
vendored
@ -38,11 +38,10 @@ pipeline {
|
||||
stage('Install Dependencies') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'NEXUS_CREDS', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
|
||||
script {
|
||||
def auth = (NPM_USER + ':' + NPM_PASS).bytes.encodeBase64().toString()
|
||||
writeFile file: '.npmrc', text: "@xuqm:registry=https://nexus.xuqinmin.com/repository/npm-hosted/\n//nexus.xuqinmin.com/repository/npm-hosted/:_auth=${auth}\n"
|
||||
bat 'npm install --legacy-peer-deps'
|
||||
}
|
||||
bat """
|
||||
powershell -NonInteractive -Command "\$auth=[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(\$env:NPM_USER+':'+\$env:NPM_PASS)); @('@xuqm:registry=https://nexus.xuqinmin.com/repository/npm-hosted/','//nexus.xuqinmin.com/repository/npm-hosted/:_auth='+\$auth) | Set-Content .npmrc"
|
||||
npm install --legacy-peer-deps
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,11 +66,10 @@ pipeline {
|
||||
stage('Publish to Nexus') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'NEXUS_CREDS', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
|
||||
script {
|
||||
def auth = (NPM_USER + ':' + NPM_PASS).bytes.encodeBase64().toString()
|
||||
writeFile file: '.npmrc', text: "@xuqm:registry=https://nexus.xuqinmin.com/repository/npm-hosted/\n//nexus.xuqinmin.com/repository/npm-hosted/:_auth=${auth}\n"
|
||||
bat "npm publish --workspaces --registry %NEXUS_REGISTRY%"
|
||||
}
|
||||
bat """
|
||||
powershell -NonInteractive -Command "\$auth=[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(\$env:NPM_USER+':'+\$env:NPM_PASS)); @('@xuqm:registry=https://nexus.xuqinmin.com/repository/npm-hosted/','//nexus.xuqinmin.com/repository/npm-hosted/:_auth='+\$auth) | Set-Content .npmrc"
|
||||
npm publish --workspaces --registry %NEXUS_REGISTRY%
|
||||
"""
|
||||
}
|
||||
}
|
||||
post {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户