fix: use ACR_PASSWORD credential and remove branch condition
这个提交包含在:
父节点
c59adf7f81
当前提交
b35fb46726
25
Jenkinsfile
vendored
25
Jenkinsfile
vendored
@ -6,7 +6,6 @@ pipeline {
|
|||||||
string(name: 'VERSION', defaultValue: '', description: '发布版本号(留空使用 package.json 中的 version)')
|
string(name: 'VERSION', defaultValue: '', description: '发布版本号(留空使用 package.json 中的 version)')
|
||||||
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行测试')
|
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行测试')
|
||||||
booleanParam(name: 'PUBLISH', defaultValue: true, description: '是否发布到 Nexus npm 仓库')
|
booleanParam(name: 'PUBLISH', defaultValue: true, description: '是否发布到 Nexus npm 仓库')
|
||||||
string(name: 'IMAGE_TAG', defaultValue: 'latest', description: 'npm 版本 Tag')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
@ -26,11 +25,11 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
checkout scm
|
checkout scm
|
||||||
script {
|
script {
|
||||||
env.GIT_COMMIT_SHORT = bat(script: '@git rev-parse --short HEAD', returnStdout: true).trim()
|
env.GIT_COMMIT_SHORT = bat(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||||
if (params.VERSION?.trim()) {
|
if (params.VERSION?.trim()) {
|
||||||
bat "npm version ${params.VERSION} --no-git-tag-version"
|
bat "npm version ${params.VERSION} --no-git-tag-version"
|
||||||
}
|
}
|
||||||
env.PUBLISH_VERSION = bat(script: '@node -p "require(\'./package.json\').version"', returnStdout: true).trim()
|
env.PUBLISH_VERSION = bat(script: 'node -p "require(\\"./package.json\\").version"', returnStdout: true).trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +40,6 @@ pipeline {
|
|||||||
echo "构建分支: ${params.BRANCH}"
|
echo "构建分支: ${params.BRANCH}"
|
||||||
echo "发布版本: ${env.PUBLISH_VERSION}"
|
echo "发布版本: ${env.PUBLISH_VERSION}"
|
||||||
echo "Git Commit: ${env.GIT_COMMIT_SHORT}"
|
echo "Git Commit: ${env.GIT_COMMIT_SHORT}"
|
||||||
echo "npm Tag: ${params.IMAGE_TAG}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,14 +73,13 @@ pipeline {
|
|||||||
expression { return params.PUBLISH }
|
expression { return params.PUBLISH }
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(credentialsId: 'nexus-npm-credentials', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
|
script {
|
||||||
bat """
|
withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'TOKEN')]) {
|
||||||
@echo off
|
bat """
|
||||||
npm config set registry %NEXUS_REGISTRY%
|
npm config set registry %NEXUS_REGISTRY%
|
||||||
for /f "delims=" %%i in ('powershell -noprofile -command "[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('%NPM_USER%:%NPM_PASS%'))"') do set B64_AUTH=%%i
|
npm publish --workspaces --registry %NEXUS_REGISTRY%
|
||||||
echo //nexus.xuqinmin.com/repository/npm-hosted/:_auth=%B64_AUTH%> .npmrc
|
"""
|
||||||
npm publish --workspaces --registry %NEXUS_REGISTRY% --tag %IMAGE_TAG%
|
}
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,12 +90,12 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
echo "RN SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})"
|
echo "RN SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})"
|
||||||
if (params.PUBLISH) {
|
if (params.PUBLISH) {
|
||||||
echo "已发布到 Nexus npm 仓库: ${NEXUS_REGISTRY},Tag: ${params.IMAGE_TAG}"
|
echo "已发布到 Nexus npm 仓库: ${NEXUS_REGISTRY}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo 'RN SDK 构建失败,请检查日志'
|
echo "RN SDK 构建失败,请检查日志"
|
||||||
}
|
}
|
||||||
always {
|
always {
|
||||||
bat 'npm config delete registry 2>nul || ver>nul'
|
bat 'npm config delete registry 2>nul || ver>nul'
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户