ci: use dind container and person-photo project

This commit is contained in:
2026-11-28 11:27:04 +08:00
parent 9278f3baf9
commit 5db4b321d8

10
Jenkinsfile vendored
View File

@@ -1,9 +1,9 @@
pipeline { pipeline {
agent { label 'docker' } // 需要先在 Jenkins 配好 label=docker 的动态构建 Pod agent { label 'docker' }
environment { environment {
HARBOR = '192.168.8.11:30002' HARBOR = '192.168.8.11:30002'
PROJECT = 'harbor-cicd' PROJECT = 'person-photo'
IMAGE_NAME = 'demo-app' IMAGE_NAME = 'demo-app'
IMAGE_TAG = "${env.BUILD_NUMBER}" IMAGE_TAG = "${env.BUILD_NUMBER}"
} }
@@ -14,15 +14,18 @@ pipeline {
} }
stage('构建镜像') { stage('构建镜像') {
steps { steps {
container('docker') {
sh """ sh """
docker build -t ${HARBOR}/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} . docker build -t ${HARBOR}/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} .
docker tag ${HARBOR}/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} ${HARBOR}/${PROJECT}/${IMAGE_NAME}:latest docker tag ${HARBOR}/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} ${HARBOR}/${PROJECT}/${IMAGE_NAME}:latest
""" """
} }
} }
}
stage('推送镜像') { stage('推送镜像') {
steps { steps {
withCredentials([usernamePassword(credentialsId: 'harbor-robot', container('docker') {
withCredentials([usernamePassword(credentialsId: 'harbor-cred',
usernameVariable: 'HARBOR_USER', usernameVariable: 'HARBOR_USER',
passwordVariable: 'HARBOR_PASS')]) { passwordVariable: 'HARBOR_PASS')]) {
sh """ sh """
@@ -34,4 +37,5 @@ pipeline {
} }
} }
} }
}
} }