Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67060

the plugin couldn't catch the variable that configured in environment part of declarative pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None

      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 in jenkins level that the Jenkins didn't transfer the pipeline environment variables to plugins .  Hope your help, Thanks.

      (At first I tried report a bug to generic-webhook-trigger-plugin ,but seems it's not the plugin issue )

       

       

      ......
      
      parameters {
          string(name: "action", defaultValue : "toBuild", description: "something")
      }
      
      environment { 
          ci_branch = "master"
      }
      
      triggers {
          GenericTrigger(
          genericVariables: [
              [key: 'branch', value: '$.ref', expressionType: "JSONPath"],
              [key: 'repository', value: '$.repository.full_name', expressionType: "JSONPath"]
          ],
      
          causeString: "Auto deployed ",
      
          token: 'ServiceTempQA',
          tokenCredentialId: '',
      
          printContributedVariables: true,
          printPostContent: true,
      
          silentResponse: false,
      
          regexpFilterText: '$branch',
          regexpFilterExpression: 'refs/heads/' + env.ci_branch
          )
      }
      
      ......

       

       

            Unassigned Unassigned
            shenmou98 yajun
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: