diff --git a/Jenkinsfile.ops-web b/Jenkinsfile.ops-web index 80cf318..4228709 100644 --- a/Jenkinsfile.ops-web +++ b/Jenkinsfile.ops-web @@ -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')]) { diff --git a/Jenkinsfile.tenant-web b/Jenkinsfile.tenant-web index 304dbcc..efbda53 100644 --- a/Jenkinsfile.tenant-web +++ b/Jenkinsfile.tenant-web @@ -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')]) {