Jenkins-How to achieve the two jobs are mutual dependency

587 views Asked by At

Jenkins CI is a very powerful tool, some plugins can be installed using it. Lately I have had a demand about two parallel processing jobs. We know that a lot of plugins have achieved this functionality, such as join plugin, Trigger parameterized plugin and so on. However I need another functionality as well.

The new functionality we want is the following:
Job A and Job B are processing parallel, if job A build fails, then Job B stops running instantly.

I haven't found any plugin achieving that.

Can you help me and inform me if there is any plugin with such functionality?

Thank you very much!

3

There are 3 answers

1
afxentios On

You can use Post Build task plugin on your Job A and Job B.

You can set it to run when the jobs are failed: Log Text -> BUILD FAILED

And when the build is failed you can execute a Script to stop the job you want to be stopped using the jenkins API as it is being discussed here.

http://<Jenkins_URL>/job/<Job_Name>/<Build_Number>/stop
1
Ankit Gupta On

Use DSL Script with Build Flow plugin.

     JOB A
       |------> JOB B
       |------> JOB C 
                  |------> JOB D

try this Example for your execution:

build("job A")

parallel ( {build("job B")} {build("job C")} )

build("job D")

0
Ingyu Seo On

You can use pipeline parallel keyword.

stage('parallel job'){
        parallel{
            stage('job1'){
                steps{ build 'job-1'}
            }
            stage('job2'){
                steps{ build 'job-2'}
            }
        }
    }

Job-1 and Job-2 runs in parallel. If job-1 fails while job-2 is running, then job2 is aborted.

It goes to next stage, only if all parallel stages are done in success.