Immutable solution version
How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?
Complete solution
Shows how to fix how can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Second, from a multibranch project, you can use the environment variable BRANCH_NAME to make logic conditional on the current branch. Update: stage 'test-downstream' node { def job = build job: 'some-downtream-job-name' } Still, when executed I get an error No parameterized job named
Steps
- First of all, it is a waste of an executor slot to wrap the build step in node . Your upstream executor will just be sitting idle for no reason. Second, from a multibranch project, you can use the environment variable BRANCHNAME to make logic conditional on the current branch. Third, the job parameter takes an absolute or relative job name. If you give a name without any path qualification, that would refer to another job in the same folder, which in the case of a multibranch project would mean another branch of the same repository. Thus what you meant to write is probably if (env.BRANCHNAME == 'master') { build '../other-repo/master' }
When to use
You are seeing this: First of all, it is a waste of an executor slot to wrap the build step in node. Use this skill when you run into "How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: How can I trigger build of another job from inside the Jenkinsfile ? I assume that this job is another repository under the same github organization , one that already has its own Jenkins file. I also want to do this only if the branch name is master, as it doesn't make sense to trigger downstream builds of any local branches. Update: stage 'test-downstream' node { def job = build job: 'some-downtream-job-name' } Still, when executed I get an error No parameterized job named
Verified resolution: First of all, it is a waste of an executor slot to wrap the build step in node . Your upstream executor will just be sitting idle for no reason. Second, from a multibranch project, you can use the environment variable BRANCHNAME to make logic conditional on the current branch. Third, the job parameter takes an absolute or relative job name. If you give a name without any path qualification, that would refer to another job in the same folder, which in the case of a multibranch project would mean another branch of the same repository. Thus what you meant to write is probably if (env.BRANCHNAME == 'master') { build '../other-repo/master' }
Source URL: https://stackoverflow.com/questions/36306883/how-can-i-trigger-another-job-from-a-jenkins-pipeline-jenkinsfile-with-github
By @issueatlas · Version 3 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_kKRIo36vIGgb7l0HvATfhQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin? <span>— Vectle</span></a>