<p>I suspect this job name is the issue:</p>
<pre><code>build job: 'second_job_name'
</code></pre>
<p>In a Multibranch pipeline, there are typically folders in the job name.  For instance, if you have a Multibranch project named &quot;my_project&quot;, a repo in that project named &quot;my_repo&quot;, and a branch within that repo that you wish to build, let's say &quot;master&quot;, then your build command would look like:</p>
<pre><code>build job: 'my_project/my_repo/master'
</code></pre>
<p>If you only specify up to the project or repo level in your job name, but don't include the branch, instead of running a build for the branch, Jenkins will scan for updates to all branches within that project/repo, and build any new commits which it hasn't yet built.  This results in exactly the symptoms you described:</p>
<blockquote>
<p>The only time this setup works as expected, is when there are new commits to all 3 git repos. Then all 3 jobs are triggered sequentially without issues.</p>
</blockquote>

CC BY-SA 4.0
2021-03-31T14:25:01.570Z
Adding the branch i.e. `build job: my_project_name/master` actually seems to have solved the problem. Thanks a lot!
pats
CC BY-SA 4.0
2021-03-09T17:08:39.287Z
2021-03-09T17:08:39.287Z
jayhendren
<p>I have three separate Multibranch pipeline jobs set up on Jenkins, which I want to be called sequentially as downstream-jobs. Please note that, all these 3 jobs have <strong>separate</strong> git repositories!</p>
<p>Each job has its own Jenkinsfile.</p>
<p>The first job is always triggered manually by me through the Jenkins UI. At the last stage of the 1st job's Jenkinsfile, the second job is being triggered, as shown below. (The second job triggers the third job, in the same way)</p>
<pre><code>stage('Trigger second job')
{
   steps {
       build job: 'second_job_name', propagate: true, wait: false
   }
}
</code></pre>
<p>Now this step always seems to be executed successfully when the first job ends, no errors or warnings show up on the logs. This should mean that the second downstream job has been called, but unfortunately that's not always the case:</p>
<ul>
<li>Sometimes the first job triggers the second job, but the second job never actually triggers the third one, although it seems to pass the corresponding Jenkinsfile stage.</li>
<li>Sometimes the first job completes but never triggers the second job at all.</li>
</ul>
<p>The only time this setup works as expected, is when there are <strong>new commits to all 3 git repos</strong>. Then all 3 jobs are triggered sequentially without issues.</p>
<p>Does anyone know the reason behind this inconsistent behavior?
Is it maybe because the jobs are based on different git repos?
Is there anything I can do to fix this?</p>
<p>Thanks</p>

<jenkins><jenkins-pipeline><jenkinsfile>
Jenkins downstream pipeline jobs not always triggered as expected
pats
# Jenkins downstream pipeline jobs not always triggered as expected

(Asked by: username_0 on 2021-03-08)

I have three separate Multibranch pipeline jobs set up on Jenkins, which I want to be called sequentially as downstream-jobs. Please note that, all these 3 jobs have separate git repositories!
Each job has its own Jenkinsfile.
The first job is always triggered manually by me through the Jenkins UI. At the last stage of the 1st job's Jenkinsfile, the second job is being triggered, as shown below. (The second job triggers the third job, in the same way)
stage('Trigger second job')
{
   steps {
       build job: 'second_job_name', propagate: true, wait: false
   }
}

Now this step always seems to be executed successfully when the first job ends, no errors or warnings show up on the logs. This should mean that the second downstream job has been called, but unfortunately that's not always the case:

Sometimes the first job triggers the second job, but the second job never actually triggers the third one, although it seems to pass the corresponding Jenkinsfile stage.
Sometimes the first job completes but never triggers the second job at all.

The only time this setup works as expected, is when there are new commits to all 3 git repos. Then all 3 jobs are triggered sequentially without issues.
Does anyone know the reason behind this inconsistent behavior?
Is it maybe because the jobs are based on different git repos?
Is there anything I can do to fix this?
Thanks

**Tags:** jenkins, jenkins-pipeline, jenkinsfile


---

## 1 answers

### Answer by username_1 on 2021-03-09. Score: 1 | Accepted answer

I suspect this job name is the issue:
build job: 'second_job_name'

In a Multibranch pipeline, there are typically folders in the job name.  For instance, if you have a Multibranch project named "my_project", a repo in that project named "my_repo", and a branch within that repo that you wish to build, let's say "master", then your build command would look like:
build job: 'my_project/my_repo/master'

If you only specify up to the project or repo level in your job name, but don't include the branch, instead of running a build for the branch, Jenkins will scan for updates to all branches within that project/repo, and build any new commits which it hasn't yet built.  This results in exactly the symptoms you described:

The only time this setup works as expected, is when there are new commits to all 3 git repos. Then all 3 jobs are triggered sequentially without issues.

> **Comments:**
> **username_0**: Adding the branch i.e. `build job: my_project_name/master` actually seems to have solved the problem. Thanks a lot!  

---

