chore(ci): 移除 DEPLOY 和 NO_CACHE 参数,构建后必然部署
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
0572bbdd38
当前提交
6b94c30628
@ -3,8 +3,6 @@ pipeline {
|
||||
|
||||
parameters {
|
||||
string(name: 'IMAGE_TAG', defaultValue: 'latest', description: '镜像 Tag')
|
||||
booleanParam(name: 'DEPLOY', defaultValue: true, description: '构建后是否自动部署')
|
||||
booleanParam(name: 'NO_CACHE', defaultValue: false, description: '禁用 Docker 构建缓存(缓存错误时使用)')
|
||||
}
|
||||
|
||||
environment {
|
||||
@ -44,15 +42,12 @@ pipeline {
|
||||
withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) {
|
||||
script {
|
||||
def fullImage = "${env.ACR_REGISTRY}/${env.ACR_NAMESPACE}/${env.IMAGE_NAME}:${params.IMAGE_TAG}"
|
||||
def cacheArgs = params.NO_CACHE
|
||||
? '--no-cache'
|
||||
: "--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${fullImage}"
|
||||
def gitCommit = env.GIT_COMMIT ?: 'unknown'
|
||||
bat """
|
||||
docker login ${env.ACR_REGISTRY} -u ${env.ACR_USERNAME} -p %ACR_PASS%
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker pull --platform=linux/amd64 ${fullImage} || echo Pull failed, will build fresh
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} ${cacheArgs} -t ${fullImage} .
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${fullImage} -t ${fullImage} .
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker push ${fullImage}
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
@ -65,7 +60,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Deploy to Production') {
|
||||
when { expression { return params.DEPLOY } }
|
||||
steps {
|
||||
lock('prod-deploy') {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) {
|
||||
|
||||
@ -3,8 +3,6 @@ pipeline {
|
||||
|
||||
parameters {
|
||||
string(name: 'IMAGE_TAG', defaultValue: 'latest', description: '镜像 Tag')
|
||||
booleanParam(name: 'DEPLOY', defaultValue: true, description: '构建后是否自动部署')
|
||||
booleanParam(name: 'NO_CACHE', defaultValue: false, description: '禁用 Docker 构建缓存(缓存错误时使用)')
|
||||
}
|
||||
|
||||
environment {
|
||||
@ -44,15 +42,12 @@ pipeline {
|
||||
withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) {
|
||||
script {
|
||||
def fullImage = "${env.ACR_REGISTRY}/${env.ACR_NAMESPACE}/${env.IMAGE_NAME}:${params.IMAGE_TAG}"
|
||||
def cacheArgs = params.NO_CACHE
|
||||
? '--no-cache'
|
||||
: "--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${fullImage}"
|
||||
def gitCommit = env.GIT_COMMIT ?: 'unknown'
|
||||
bat """
|
||||
docker login ${env.ACR_REGISTRY} -u ${env.ACR_USERNAME} -p %ACR_PASS%
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker pull --platform=linux/amd64 ${fullImage} || echo Pull failed, will build fresh
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} ${cacheArgs} -t ${fullImage} .
|
||||
docker build --platform=linux/amd64 -f ${env.DOCKERFILE} ${env.BUILD_ARGS} --build-arg GIT_COMMIT=${gitCommit} --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${fullImage} -t ${fullImage} .
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
docker push ${fullImage}
|
||||
if %errorlevel% neq 0 exit /b 1
|
||||
@ -65,7 +60,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Deploy to Production') {
|
||||
when { expression { return params.DEPLOY } }
|
||||
steps {
|
||||
lock('prod-deploy') {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户