0

I am currently creating a multibranch pipeline from BitBucket, which will build all branches automatically. That would be extremely helpful for pull requests and overall save a lot of time. However this specific project is a little bit different - it is a web application and it is built with 2 different Jenkins jobs:

Job 1: Checkout files from Version Control (Subversion and Git) and if successfull trigger Job 2 (from the job configuration).

Job 2: Transfer the files from Job 1 to node, and execute the deployment scripts. There is a lot of extra configuration in the job, which I do not need to explain. If this job is successful, the web application is deployed.

However, how the multibranch pipeline works is that it points to the Jenkinsfile of each branch (which starts Job 1) and builds that. Everytime is successful, however it doesn't trigger Job 2. Also in BitBucket it shows up as successfull build for all branches, because it only looks for this specific job.

Is there a way I can make individual rules for the branch jobs, so that they trigger another job, and that BitBucket looks for that job as a reference if a build has passed or failed? I would very much not like to combine the whole functionality in a single JenkinsFile, because it would be a massive change. Thank you.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Gergan Zhekov
  • 944
  • 1
  • 8
  • 27

1 Answers1

0

It is not clear what actions you do in your second Job to understand if it is common for all the jobs or it is very different for each branch.

First with the assumption, your second job is common for all the branches, you can have a Jenkins file in each branch which triggers the common job (based on another jenkins file which is in a common location) in it.

Second, if the functionality is different for each branch, what I would suggest is come up with a generic functions and try passing parameters based on the requirement of each branch in the first Jenkins file.

This is just an idea. If you can explain little bit more about the second jobs behaviour, I might be able to throw some more ideas to help you.

NIK
  • 1,089
  • 13
  • 22