I don't know how to setup the stash notifier plugin on a multibranch pipeline. The configuration page does not have a 'Post-build Actions section'.
Stash Notifier now supports Pipelines as of version 1.11.
From the examples in the README:
node {
step([$class: 'StashNotifier']) // Notifies the Stash Instance of an INPROGRESS build
try {
// Do stuff
currentBuild.result = 'SUCCESS' // Set result of currentBuild !Important!
} catch(err) {
currentBuild.result = 'FAILED' // Set result of currentBuild !Important!
}
step([$class: 'StashNotifier']) // Notifies the Stash Instance of the build result
}
While it says that setting currentBuild.result is "!Important!", my experience has been that this is only the case if your steps aren't already doing that. For example, if you have sh "false"
, you don't need to wrap that in a try/catch because the sh
step will set the build result to failed on a non-zero exit code. This should only be necessary if you need custom success/failure logic.
I think it is still not compatible with the pipeline or multibranch pipeline job type.
I think Abhijeet Kamble means that you can just use a http client or curl to send the updates yourself.
Something like this:
withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: "$env.componentCredentialsId",
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
writeFile file: 'build.json', text: "{\"state\": \"SUCCESSFUL\", \"key\": \"${env.JOB_NAME}\", \"name\": \"${env.BUILD_TAG}\", \"url\": \"${env.BUILD_URL}\"}"
sh '''curl -u $USERNAME:$PASSWORD -H "Content-Type: application/json" -X POST $URL -d @build.json'''
}
Do note that it is a very simple example, not as sophisticated as the plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With