ci: use dind container and person-photo project
This commit is contained in:
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
@@ -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 """
|
||||||
@@ -35,3 +38,4 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user