Reputation: 1432
I have a job (JobA) which, upon success, builds JobB. The Jenkinsfile for JobA contains a post section like this:
post {
success {
build job: 'JobB', wait: false
}
}
The problem is that when JobB
is disabled, JobA will fail no matter what with the following message:
ERROR: Failed to trigger build of JobB
Finished: FAILURE
Can I prevent JobA from failing when JobB is disabled while still using declarative syntax?
Upvotes: 2
Views: 1750
Reputation: 75
Before triggering the post job, you can first check if JobB is enabled/disabled via isBuildable().
Jenkins.instance.getItem("JobB").isBuildable()
Upvotes: 2