I've a jenkins pipeline which uses generic webhook trigger and runs a build on the branch mentioned in the triggers content:
triggers {
GenericTrigger (
genericVariables: [
[
key: 'ref',
regexpFilter: '^refs/heads/',
value: '$.changes[0].refId',
defaultValue: 'master'
],
[
key: 'committer_name',
value: '$.actor.displayName'
]
],
token: 'default_token',
printContributedVariables: true,
printPostContent: true,
causeString: 'Commit on branch $ref by $committer_name'
)
}
In the job, I've defined the variable refas branch source:

This works well when triggered properly.
But I'd like to run the same job also by means of the "build now" button in jenkins. It's obvious that I've to define the parameter in another way, but how?
What I already tried:
def ref = 'master'
environment {
ref = 'master'
}
I always get en error indicating, that the variable is not set properly:
> git rev-parse origin/$ref^{commit} # timeout=10
Any hints? Thanks a lot!