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' //使用變量
}