3

I have a build flow which builds 4 jobs in sequence

eg;

build(Job 1)
build(Job 2)
build(Job 3)
build(Job 4)

I want to run Job 4 even if any of the previous job fails also . How can I do that in the build flow ?

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
Sreevalsa E
  • 905
  • 5
  • 17
  • 39

3 Answers3

5

you can set propagate to false, that will ensure your workflow will continue if particular job fails:

build job: '<job_name>', propagate: false
vehovmar
  • 1,557
  • 1
  • 14
  • 24
1

For me, propagate: false didn't worked, So I used ignore(FAILURE) instead in my BuildFlow, to make sure that all the jobs in flow executes, even if there are failures. (Ref)

  ignore(FAILURE) {
        build("JobToCall",  Param1: "param1Val", Param2: "param2Val")
    }
Yogi
  • 9,174
  • 2
  • 46
  • 61
0

You can use Jenkins Workflow Plugin as follows:

try {
  build 'A'
} catch(e) {
  echo 'Build for job A failed'
}
try {
  build 'B'
} catch(e) {
  echo 'Build for job B failed'
}

You can extend this idiom to any number of jobs or any combination of success/failure flow you want (for example, adding build steps inside catches if you want to build some job in case another failed).

amuniz
  • 3,292
  • 2
  • 20
  • 22