Jenkins - conditions between assembly steps

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

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

  • the first step is a shell or python script that checks for this condition.

  • the second step is the actual assembly of Maven

The second step should be called only if the status check in step 1 returned "true".

Is there any way to do this? Well, I think I could return exit code 1 to the first script if the condition is not met. This will stop the build right away, but the job will be marked as "crash". So this is not a good idea, as the red icon makes my users panic; -)

Any other ideas around this?

Cheers, Frank

+4
source share
1 answer

We do something similar with our own Jenkins installation.

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. At one stage of the assembly, some aspects of the code are considered and it is decided whether the assembly is needed or not. If necessary, it uses CURL to initiate the start of a build project. The "build" project receives the source code and builds - it does not bother to figure out whether to build or not - it always does.

By separating the two tasks, manual assembly also starts easily, without worrying that the should-I-build logic ignores and stops the assembly.

+3
source

All Articles