Closed BarelElbaz closed 1 year ago
Create both variables. One resolving it for PR and one resolving it for branch push.
Use both variables in the text. Only one of them will be resolved to the value.the other one, not found in the webhook, will resolve to nothing.
Write the regexp as usual.
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.changes[0].refId'],
[key: 'ref2', value: '$.pullRequest.fromRef.id']
],
causeString: 'Triggered on $ref',
token: 'test',
// tokenCredentialId: '',
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
regexpFilterText: '$ref$ref2',
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
)
**ref refers to push**
**ref2 refers to PR**
This should work?
Thanks but how can I detect which trigger was triggered me?
I tried to check with IF statement but I get error: No such property ref2
because one of the refs will not be declared
You can google on how to check if variable exists in Jenkins.
You can also set some default values.
Hi, I have a multi branch pipeline running with bitbucket cloud with this plugin https://plugins.jenkins.io/cloudbees-bitbucket-branch-source/
@tomasbjerre
Regarding our discussion, when I use:
regexpFilterText: '$ref$ref2'
I can't use ^ and $ on my filter expression (causes feature/testing trigerring also for feature/testing2 branch)
currently expression is:
'refs/heads/' + BRANCH_NAME
but I need something like:
'^refs/heads/' + BRANCH_NAME + '$'
and due to the fact that sometime ref or ref2 are not defined the regex aborting my trigger
Hey, I'm trying to trigger Jenkins multibranch pipeline on two events: 1) push 2) pull request approved
There is any solution for this? SCM: bitbucket the payload of the events are comletly different so I can't use same key for determine branch
What I try to do is to create multiple generic variables that fits the 2 different events and check if one of them equals to null and then determine what event was trigger the job.
The problem is:
regexpFilterText
andregexpFilterExpression
fields can't contain logic of two variables with 'OR' operation between themCan you help me?