代码拉取完成,页面将自动刷新
同步操作将从 极客时间/Django 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
pipeline {
agent any
stages {
stage('Checkout Source') {
steps {
git url:'https://gitee.com/geektime-geekbang/django.git', branch:'master'
}
}
stage('Docker Build') {
steps {
sh "docker build -t ihopeit/django-recruitment:${env.BUILD_NUMBER} ."
sh "docker tag ihopeit/django-recruitment:${env.BUILD_NUMBER} registry.cn-beijing.aliyuncs.com/ihopeit/django-recruitment:${env.BUILD_NUMBER}"
}
}
stage('Docker Push') {
steps {
withCredentials([usernamePassword(credentialsId: 'aliyunhub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword} registry.cn-beijing.aliyuncs.com"
sh "docker push registry.cn-beijing.aliyuncs.com/ihopeit/django-recruitment:${env.BUILD_NUMBER}"
}
}
}
stage('Docker Remove Image') {
steps {
sh "docker rmi registry.cn-beijing.aliyuncs.com/ihopeit/django-recruitment:${env.BUILD_NUMBER}"
sh "docker rmi ihopeit/django-recruitment:${env.BUILD_NUMBER}"
}
}
stage('Apply Kubernetes Files') {
steps {
// 在 jenkins 的 pipeline 配置中替换掉下面的 caCertificate 的内容
kubeconfig(caCertificate: 'base64-encoded-certificate-authority-data==',credentialsId: 'kubeconfig', serverUrl: 'https://192.168.0.235:6443') {
// 部署到 kubernetes
sh 'echo deploy to kubernetes'
sh 'kubectl apply -f k8s/web-claim0-persistentvolumeclaim.yaml '
sh 'kubectl apply -f k8s/redis-service.yaml'
sh 'kubectl apply -f k8s/flower-service.yaml'
sh 'kubectl apply -f k8s/web-service.yaml'
sh 'kubectl apply -f k8s/redis-deployment.yaml'
sh 'cat k8s/celery-deployment.yaml | sed "s/{{BUILD_NUMBER}}/$BUILD_NUMBER/g" | kubectl apply -f -'
sh 'cat k8s/flower-deployment.yaml | sed "s/{{BUILD_NUMBER}}/$BUILD_NUMBER/g" | kubectl apply -f -'
sh 'cat k8s/web-deployment.yaml | sed "s/{{BUILD_NUMBER}}/$BUILD_NUMBER/g" | kubectl apply -f -'
}
}
}
}
post {
success {
sh "echo Pipeline is successfully completed."
}
failure {
sh "echo Pipeline failed. Please check the logs."
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。