Jenkins - conditions between build steps

女生的网名这么多〃 提交于 2019-12-19 09:16:53

问题


I want to build a Maven project using Jenkins. However, the project only must be built if a certain file in the SVN repository has changed (and contains a special key)

So my plan is to create a job with two build steps:

  • the first step executes a shell or python script that checks that "condition".

  • the second step is the actual Maven build

The second step only must be invoked if the condition check in step 1 returned "true".

Is there a possibility to do so? Well, I guess I could return an exit code 1 in the first script if the condition is not met. This will stop the build at once, but the job will be marked as "failed". So this is not a good idea since the red icon makes my users panic ;-)

Any other ideas around this?

Cheers, Frank


回答1:


We do something similar with our own Jenkins setup.

We have a "trigger" job that monitors SVN on a periodic basis. When a change occurs in SVN, the trigger job executes its build steps. One of the build steps examines some aspects of the code and decides whether a build is necessary or not. If it is necessary, it uses CURL to initiate the start of a the "build" project. The "build" project gets the source code and does a build - it doesn't bother to figure out whether it needs to build or not - it always does.

Having the two tasks separate also makes it easy to trigger a manual build without worrying the should-I-build logic kicking and stopping the build.



来源:https://stackoverflow.com/questions/6018619/jenkins-conditions-between-build-steps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!