使用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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。