Closed shenmou98 closed 3 years ago
Maybe because in jenkins, the generic-webhook-trigger-plugin pipeline content load before environment ? If this is true, I think it didn't make sense. because user may want to use some self environment variables in generic-webhook-trigger-plugin.
The reason I want to use variable in environment , is because in envronment variable, I can have some shell like below (the branch come from the jenkins job name) :
for example, the jenkins job name is group_my-project_master_QA
ci_branch = sh(script: 'echo ${JOB_NAME} | cut -d "_" -f 3', , returnStdout: true).trim() # ci_branch will be master
so I can have different jenkins job for different github branch, and they can share the same generic-webhook-trigger-plugin pipeline content.
I don't think this can be solved in this plugin. Perhaps you should try opening an issue here: https://www.jenkins.io/participate/report-issue/
I don't think this can be solved in this plugin. Perhaps you should try opening an issue here: https://www.jenkins.io/participate/report-issue/
Hi @tomasbjerre , I know little about Jenkins's plugin mechanism, could you pelase explain more?
The input to the plugin contains the null value. The null value is resolved before the plugin is involved.
The input to the plugin contains the null value. The null value is resolved before the plugin is involved.
@tomasbjerre but the other pipeline stages could get the correct environment variable , such as the below code, it can print the correct value of ci_branch.
stages { stage("Prepare") { steps { echo "ci_branch: ${ci_branch}" } } }
And I also created the jenkins issue https://issues.jenkins.io/browse/INFRA-2854
Hello,
when I set generic webhook in declarative pipeline like below code,
in regexpFilterExpression, it can't catch the variable "ci_branch " that I configured in enviroment, regexpFilterExpression will get a finally value: refs/heads/null , the expected value should be refs/heads/master And by the way , if the variable configured in pipeline parameters , regexpFilterExpression can get the correct value. And, if use some jenkins built in variables such as env.JOB_NAME, it also culd get the correct value.
I think this may be a bug. Hope your help, Thanks.
` ......
...... `