0

In jenkins plugin, claim plugin can help to claim a failure job with reasons.

And with the latest version (2.6+), it is able to run a global groovy script to do some notification whenever a claim is changed

But how can I trigger another job in this script ? it shall pass important parameters like jenkins name, build number and failure reason.

Larry Cai
  • 55,923
  • 34
  • 110
  • 156

1 Answers1

1

Finally I got answer by myself, the claim plugin is hacked using post job action, so it could be done like trigger downstream job. See code sample below:

import hudson.model.*

def job = Hudson.instance.getJob('ClaimNotify')
def build = action.owner

def causeAction = new CauseAction(new Cause.UpstreamCause(build))

Hudson.instance.queue.schedule(job,0, causeAction)

You can pass parameter there as well or in downstream job to fetch it as well.

see similar question and solution in how-do-i-dynamically-trigger-downstream-builds-in-jenkins

more information about schedule function, can check jenkins javadoc

Community
  • 1
  • 1
Larry Cai
  • 55,923
  • 34
  • 110
  • 156