user2439278
user2439278

Reputation: 1224

Jenkins Pipeline job to fetch another jenkins job build status

I have a Jenkins pipeline Job , which need to monitor the another Jenkins job (say JobA) current build and publish the status (Build Status : Success or Failure) in current pipeline stage. How to achieve that. The job(JobA) will not be triggered from the pipeline job. It will run Independently. From Pipeline job , need to fetch the status of JobA.

Upvotes: 0

Views: 1523

Answers (1)

MaratC
MaratC

Reputation: 6889

To get the last build result of Job A:

jenkins.model.Jenkins.instance.getItem("JobA").lastBuild.result

Unclear what exactly you mean by "monitor", but you may get build number of "lastBuild" and watch if it has changed.

Upvotes: 2

Related Questions