Trigger pipeline A form pipeline B in Jenkins if there is no last successful build of pipeline A

30 Views Asked by At

There are two Jenkins pipelines A and B. I want to trigger pipeline A from B depending on the values of certain env variables of last successful build of pipeline A (if it exists). How can I achieve this form pipeline B.

1

There are 1 best solutions below

0
Borbyu On

you can use Jenkins-api to collect the last success build in variable like,

curl --user {username}:{password} http://{URL}/job/{JOB-NAME}/lastFailedBuild/api/json

then use 'if' condition in first of all in pipeline B.