Groovy script to run when claims are changed. The variable action
is bound to the
hudson.plugins.claim.ClaimBuildAction instance for the claim.
Here is an example that sends messages to the configured Slack channel.
// send claim changes to Slack def build = action.owner def notifier = build.project.publishers.find { k, v -> v.class.name == 'jenkins.plugins.slack.SlackNotifier' }?.value if (notifier) { def slackServiceClass = notifier.class.classLoader.loadClass('jenkins.plugins.slack.StandardSlackService') def slackService = slackServiceClass.newInstance(notifier.teamDomain, notifier.authToken, notifier.room) if (action.claimed) { def sticky = action.isSticky() ? ', sticky' : '' def assignedBy = (action.assignedBy == action.claimedBy) ? '' : ", assigned by ${action.assignedBy}" slackService.publish("${action.claimedBy} claimed: ${build}${sticky}${assignedBy} (<${build.absoluteUrl}|Open>)\n${action.reason}", 'warning') } else { slackService.publish("claim dropped for: ${build} (<${build.absoluteUrl}|Open>)", 'danger') } }