jenkins pipeline :
pipeline { agent any parameters { string(name: ‘git_version‘, defaultValue: ‘v1.1‘, description: ‘请输出你要上线tag版本‘) } stages{ stage(‘获取代码‘) { steps { checkout([$class: ‘GitSCM‘, branches: [[name: ‘${git_version}‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘d12aa37e-dfa0-4aaa-86dc-f2297fbf60f5‘, url: ‘git@gitlab.xxx.com:dev/monitor.git‘]]]) } } stage(‘代码检测‘){ steps { echo "sonarqube check...." } } stage(‘代码构建‘){ steps { echo "maven build....." } } stage(‘确定要部署吗?‘) { steps { input message: ‘是否部署‘ } } stage(‘代码部署‘){ steps { sh ‘sh -x /scripts/deploy_html_tag.sh‘ } } } //所有的stages执行完毕后执行的操作 post { failure { //构建失败通知 dingTalk accessToken: ‘1cb431e94ead339f00c137f749561b0e9a2a83f4c5b96ce88d486ffac6310905‘,imageUrl: ‘‘, jenkinsUrl: ‘http://jenkins.xxxx.com:8080/‘, message: ‘代码部署失败‘, notifyPeople: ‘phone‘ } success { //构建成功通知 dingTalk accessToken: ‘1cb431e94ead339f00c137f749561b0e9a2a83f4c5b96ce88d486ffac6310905‘,imageUrl: ‘‘, jenkinsUrl: ‘http://jenkins.xxx.com:8080/‘, message: ‘代码部署成功‘, notifyPeople: ‘phone‘ } } }
原文:https://www.cnblogs.com/oldsjf/p/11761076.html