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' //使用变量
}
鸡肉是我的最爱!