Issue
I am using the generic webhook plugin to trigger my builds: https://plugins.jenkins.io/generic-webhook-trigger/
In the settings of this plugin it allows you to define variables based on the content of the webhook. I use this to create variable like $name & $branch.
I can use these variables inside the trigger condition for the build (I use it to check the commit is for the right branch).
What I would really like to do is have access to the variables I define here inside my actual pipeline.
So I would be able to do something like:
steps {
slackSend(channel: "#pipeline", message: 'Starting to build ${branch} for ${name}', botUser: true, color: 'good')
}
How can I get these webhook variables into my build environment variables?
Solution
Guerrilla answered this in a comment, but the fix is to use double quotes instead of single quotes as below:
steps {
slackSend(channel: "#pipeline", message: "Starting to build ${branch} for ${name}", botUser: true, color: 'good')
}
Answered By - mayurva