代码拉取完成,页面将自动刷新
pipeline {
environment {
mavenRegistry = "registry-vpc.cn-beijing.aliyuncs.com/lemonbox/questionnaire_setting_maven"
registry = "registry-vpc.cn-beijing.aliyuncs.com/lemonbox/questionnaire-java"
registryCredential = "dockerhub"
parentWorkspace = "$WORKSPACE"
FAILED_STAGE=""
CURRENT_ENVIRONMENT=""
BLUE_OR_GREEN=""
}
agent any
stages {
stage("Deply Parent") {
agent {
docker {
image mavenRegistry
registryUrl 'https://registry-vpc.cn-beijing.aliyuncs.com'
registryCredentialsId registryCredential
args '-v $HOME/.m2/repository:/root/.m2/repository -u root'
}
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
sh "mvn -U clean install -Dmaven.test.skip=true"
// 拷贝到容器外
sh "cp target/questionnaire-release-exec.jar " + parentWorkspace +"/questionnaire-release-exec.jar"
}
}
}
stage("Building image") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
docker.build(registry)
}
}
}
stage("Deploy Image") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
docker.withRegistry('https://registry-vpc.cn-beijing.aliyuncs.com', registryCredential) {
docker.image(registry).push("$GIT_COMMIT")
}
}
}
}
stage("Update k8s cluster") {
options {
timeout(time: 8, unit: 'MINUTES')
}
steps {
script {
FAILED_STAGE = env.STAGE_NAME
if (env.GIT_BRANCH == "origin/master") {
sh "kubectl config use 229638354516261836-c1ef3c2118ae344d3b5ee63c17ae6f93b"
sh "cat k8s/deployment.yml | sed 's/{{GIT_COMMIT}}/$GIT_COMMIT/g' | kubectl apply -f -"
sh "kubectl rollout status deployment/questionnaire-java"
} else {
sh "kubectl config use test"
sh "cat k8s/deployment-test.yml | sed 's/{{GIT_COMMIT}}/$GIT_COMMIT/g' | kubectl apply -f -"
sh "kubectl rollout status deployment/questionnaire-java-test"
}
}
}
}
}
post {
failure {
sh "curl -d '{\"commitId\": \"$GIT_COMMIT\", \"branch\": \"$GIT_BRANCH\", \"build\": \"$BUILD_ID\"}' -H \"Content-Type: application/json\" -X POST http://ec2-54-222-181-255.cn-north-1.compute.amazonaws.com.cn:6666/build/fail"
}
aborted {
script {
if (FAILED_STAGE == "Update k8s cluster") {
if (env.GIT_BRANCH == "origin/master") {
sh "kubectl config use 229638354516261836-c1ef3c2118ae344d3b5ee63c17ae6f93b"
sh "kubectl rollout undo deployment/questionnaire-java"
} else {
sh "kubectl config use test"
sh "kubectl rollout undo deployment/questionnaire-java-test"
}
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。