node(){
environment {
NPM_REGISTRY = "https://registry.npmmirror.com" // 淘宝源:ml-citation{ref="2" data="citationList"}
}
// 2. 参数
def harborProject = 'vue-web'
def gitBranch = 'main'
//拉取代码
stage('Pull Code') {
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
userRemoteConfigs: [[
credentialsId: 'gitlab-http-token', // 替换为有效凭证 ID
url: 'http://************/*****web.git'
]]
])
}
// 4. 生成镜像Tag
stage('Generate Tag') {
script {
def gitCommit = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
env.IMAGE_TAG = "${gitBranch}_${gitCommit}"
}
}
// 阶段 2:安装依赖 & 构建
stage('Build vue') {
nodejs("Node 22.14.0") {
sh("npm install")
sh("npm run build:prod")
}
}
}
08-23
2086

08-05
6830

05-10
572
