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