您好,登錄后才能下訂單哦!
使用Jenkins時如果GIT_COMMIT無變化該怎么辦,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
使用Jenkins時,如果GIT_COMMIT無變化,跳過構建
使用插件: conditional-buildstep
A buildstep wrapping any number of other buildsteps, controlling their execution based on a defined condition (e.g. BuildParameter).
wiki: https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin
如下圖所示,如果環境變量GIT_PREVIOUS_SUCCESSFUL_COMMIT不存在,或者GIT_COMMIT和GIT_PREVIOUS_SUCCESSFUL_COMMIT不同,才會執行構建
上圖中腳本如下:
#!/bin/bash if [ ! $GIT_PREVIOUS_SUCCESSFUL_COMMIT ];then echo "GIT_PREVIOUS_SUCCESSFUL_COMMIT is not exists." exit 0 else echo "GIT_COMMIT=[$GIT_COMMIT],GIT_PREVIOUS_SUCCESSFUL_COMMIT=[$GIT_PREVIOUS_SUCCESSFUL_COMMIT]" if [ $GIT_PREVIOUS_SUCCESSFUL_COMMIT == $GIT_COMMIT ];then echo "GIT_COMMIT is equals to GIT_PREVIOUS_SUCCESSFUL_COMMIT,skip build." exit -1 else echo "GIT_COMMIT is not equals to GIT_PREVIOUS_SUCCESSFUL_COMMIT" exit 0 fi fi
看完上述內容,你們掌握使用Jenkins時如果GIT_COMMIT無變化該怎么辦的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。