(1)拉取代码
(2)编译
(3)构建成docker镜像
(4)推送至远程镜像仓库
pipeline { agent any stages { stage('检出') { steps { checkout([$class: 'GitSCM', branches: [[name: GIT_BUILD_REF]], userRemoteConfigs: [[ url: GIT_REPO_URL, credentialsId: CREDENTIALS_ID ]]]) } } stage('编译') { steps { sh 'chmod +x ./gradlew' sh './gradlew build --stacktrace ' } } // Successfully tagged gdufs-lib/docker-repo/java-spring-app:master-7eb97c8728d09bfc714122e4da426bea41e592b0 // docker push gdufsdev-docker.pkg.coding.net/gdufs-lib/docker-repo/gdufs-lib/docker-repo/java-spring-app:master-7eb97c8728d09bfc714122e4da426bea41e592b0 // The push refers to repository [gdufsdev-docker.pkg.coding.net/gdufs-lib/docker-repo/gdufs-lib/docker-repo/java-spring-app] stage('构建镜像并推送到 CODING Docker 制品库') { steps { sh "docker login -u 1987151116@qq.com -p xxxxxxxxx$ gdufsdev-docker.pkg.coding.net" sh "docker build -t ${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} -f ${DOCKERFILE_PATH} ${DOCKER_BUILD_CONTEXT}" sh "docker tag ${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} gdufsdev-docker.pkg.coding.net/${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" sh "docker push gdufsdev-docker.pkg.coding.net/${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" } } // stage('运行') { // steps { // sh 'docker run -itd -p 8080' // } // } } environment { CODING_DOCKER_REG_HOST = "${CCI_CURRENT_TEAM}-docker.pkg.${CCI_CURRENT_DOMAIN}" CODING_DOCKER_IMAGE_NAME = "${PROJECT_NAME.toLowerCase()}/${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME}" } }
(2)登陆服务器拉去镜像
docker pull gdufsdev-docker.pkg.coding.net/gdufs-lib/docker-repo/java-spring-app:master-7eb97c8728d09bfc714122e4da426bea41e592b0
(3)
docker run -p 8777:8777 imageId
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)