admin 管理员组文章数量: 887021
2024年3月6日发(作者:casewhen嵌套查询)
node {
label 'slave'
}
} steps { sh """ echo "Clone frontend repo: ${repo_url_frontend} ${branch}" pwd """ dir("${work_dir_frontend}"){ deleteDir() git( url: "${repo_url_frontend}", credentialsId: '13*yourGitCredentialsId*14', branch: "${branch}" ) } sh """ pwd ls """ } } stage("Clone backend"){ agent {
node {
label 'slave'
}
} steps { sh """ echo "Clone frontend repo: ${repo_url_frontend} ${branch}" pwd """ dir("${work_dir_backend}"){ deleteDir() git( url: "${repo_url_backend}", credentialsId: '13*yourGitCredentialsId*14', branch: "${branch}" ) } sh """ pwd ls """ } } stage('Scp to sre-cicd') { agent {
node {
label 'slave'
}
} steps { sh """ pwd echo "rsync frontend" rsync -Lrap ${work_dir_frontend} --exclude ${work_dir_frontend}/.git e-cicdMachine.148:/data/nas-sre-prod/jenkins/apps/ if [ $? -ne 0 ] then echo "Found some error when copy the frontend repo" exit 1 fi echo "rsync backend" rsync -Lrap ${work_dir_backend} --exclude ${work_dir_backend}/.git e-cicdMachine.148:/data/nas-sre-prod/jenkins/apps/ if [ $? -ne 0 ] then
then echo "Found some error when copy the backend repo" exit 1 fi """ } }
stage('generate frontend') { agent {
node {
label 'SRE_BUILD_NODE'
}
} steps { sh """ echo 'generate frontend files' pwd ls docker rm -f ${work_dir_frontend} || pwd docker run --name=${work_dir_frontend} -v /data/nas-sre-prod/jenkins/apps/${work_dir_frontend}:/home/ ${build_front_docker} bash /home/ docker rm -f ${work_dir_frontend} || pwd ls """ } }
stage('copy frontend to backend') { agent {
node {
label 'SRE_BUILD_NODE'
}
} steps { sh """ echo 'copy frontend to backend' pwd
ls cp /data/nas-sre-prod/jenkins/apps/${work_dir_frontend}/src/get_ /data/nas-sre-prod/jenkins/apps/${work_dir_backend}/src/templates/ """ } } stage('Build docker images') { agent {
node {
label 'SRE_BUILD_NODE'
}
} steps { sh """ echo 'build docker image' pwd
ls cd /data/nas-sre-prod/jenkins/apps/${work_dir_backend}/ if [ ! -f Dockerfile ] then echo "No available dockerfile in workspace" fi if [ ! -f build_ ] then echo "No available build_ in workspace" fi bash build_ ${docker_repo} ${image_version} pwd
ls """ } }
stage('Set tag') { agent {
node {
label 'slave'
}
} steps { dir("${tag_dir}"){ sh """ pwd ls echo "${branch} => ${image_version}" git tag -m "Build docker image ${image_version} for ${branch}/${image_version}" ${branch}/${image_version} && git describe && git push origin ${branch}/${image_version} ls """ } } } stage('check deploy exists') { agent {
node {
label 'SRE_NODE' }
} steps { echo 'Hello, check deployment ${cluster} ${namespace}/${deployment} exists' sh "/usr/local/bin/kubectl --kubeconfig /home/yourHome/.kube/config-${cluster} -n ${namespace} get deploy ${deployment}" } }
stage('deploy to k8s') { agent {
node {
label 'SRE_NODE' }
} steps { echo 'deploy to k8s' sh """ /usr/local/bin/kubectl --kubeconfig /home/yourHome/.kube/config-${cluster} -n ${namespace} set image deployment/${deployment} ${container_name}=your_docker_image_repo/${docker_repo}:${image_version} """ } } }
post { always { echo 'I have finished' } success { echo "all in one, succeed!" sh """ curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"gitlab_test_flask_two_repo notify, ${namespace}/${deployment}:${image_version}, succeed!"}}' /open-apis/bot/v2/hook/46xxx-xxx-xxx05 """ } failure { echo "all in one, failed!" sh """ curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"gitlab_test_flask_two_repo notify, ${namespace}/${deployment}:${image_version}, failed!"}}' /open-apis/bot/v2/hook/46xxx-xxx-xxx05 """ } }
}2.3 测试结果前端修改代码:后端代码修改:
版权声明:本文标题:cicd07--构建前后端一体化自动化发布流程 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1709683542h543617.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论