3

Gurus,

I have 4 jenkins jobs which I am triggering based on success and failure of previous job execution status. Is there any way I can combine all the 4 jobs in a jenkins pipeline and have the same logic of checking if the previous execution successful or not?

fallenbruce
  • 53
  • 2
  • 7
  • Jenkins Pipelines use a terminology call `stages` that allows you to break a job in to multiple blocks. Cool thing about is if a `stage` fails job will fail at there an not continue. So you can have your 4 jobs as 4 stages. If you use `declarative` pipelines you can even run stages in parallel. – Prav Nov 17 '18 at 14:36
  • 1
    thanks , but what would be the command to run a jenkins job within a stage ? – fallenbruce Nov 17 '18 at 18:56
  • If you take the triggering route, you cannot determine whether previous stages passed or failed. You will have to create a pipeline (single job) that has the existing 4 jobs as stages. – Prav Nov 17 '18 at 18:59
  • thats fine , however to execute that job in stage do I have to run curl command like to invoke jenkins from shell script or is there a particular command for that ? – fallenbruce Nov 17 '18 at 19:05
  • No, there is a built-in command for that [build](https://jenkins.io/doc/pipeline/steps/pipeline-build-step/). [Few examples here](https://stackoverflow.com/questions/36306883/how-can-i-trigger-another-job-from-a-jenkins-pipeline-jenkinsfile-with-github) – Prav Nov 17 '18 at 19:06

0 Answers0