Jenkins job can be triggered so many different ways. This article provides steps to trigger a Jenkins job from another Jenkins job.
Pre-requisites:
Scenario #1(post build) - How to trigger a Jenkins job from another Free style Job?
2. Open your any existing freestyle build job.
3. Click on Configure
4. Go to post build action
5. Add post-build action --> click on Build other projects
6. Select job name(projects) that you want to trigger by typing the name of the job and also check trigger only if build is stable
8. Build job now, once the current job is built, it will trigger the next job immediately.
Check the console output of the current job, you will see id would trigger second job
Check console output. You will see the second job got triggered by first build job.
Scenario #2 (pre-build) - How to trigger a Jenkins job from another Free style Job?
Select source job name which will be built first and then once the build is stable, it will be trigger this job. And also check trigger only if build is stable.
5. Save the job.
6. Run the first job. once that job is successful, and then it will trigger this job.
Scenario #3 - How to trigger any Jenkins job from a pipeline Job:
pipeline {
agent any
stages {
stage('Trigger Another Job') {
steps {
build job: 'mySecondJob', wait: false
}
}
}
}