jenkins pipeline中,失败后获取异常不中断业务


1. jenkins中,某一个步骤出现了错误,不中继续进行。放在pipeline的stage或者steps中即可

catchError(buildResult: 'SUCCESS', message: 'git 拉取失败') {
  // 业务代码   withCredentials([
string(credentialsId: 'token', variable: 'token')]) {     git url: "https://${token}@github.com/vi/st.git", branch: 'master'   } }

2. jenkins中对于ssh私钥,或者一些隐秘的字符串,需要在系统设置中设置credentials,然后引用到pipeline中:  


withCredentials([string(credentialsId: 'token', variable: 'token')]) { //把字符串的credentialsid 赋值到变量     git url: "https://${token}@github.com/vi/st.git", branch: 'master'   //使用变量
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM