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

Pipeline script from SCM does not expand build parameters/env variables for declarative pipeline with yamlFile specified

      Reproduce step:
      1. Create a parameterized pipeline job.
      2. Add the string parameter called `branch`
      2. Configure the pipeline definition to `Get Pipeline script from SCM`.
      3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
      4. Add the following code to the file `Jenkinsfile`.

      pipeline {
          agent {
              kubernetes {
                  label 'jks-builds'
                  yamlFile 'path/to/podTemplate.yaml'
              }
          }
      
          stages {
              stage('test') {
                  steps {
                       echo "test"
                  }
              }
          }
      }
      

      with the above reproducing steps you will get the following failed messages:

      hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
      stdout: 
      stderr: fatal: Couldn't find remote ref refs/heads/${branch}
      

      however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.

          [JENKINS-57930] Pipeline script from SCM does not expand build parameters/env variables for declarative pipeline with yamlFile specified

          jubel han created issue -
          jubel han made changes -
          Description Original: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:grovvy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          ```
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          ```

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          New: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:groovy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          ```
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          ```

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          jubel han made changes -
          Description Original: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:groovy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          ```
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          ```

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          New: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:groovy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          {code:java}
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          {code}

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          jubel han made changes -
          Description Original: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:groovy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          {code:java}
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          {code}

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          New: Reproduce step:
          1. Create a parameterized pipeline job.
          2. Add the string parameter called `branch`
          2. Configure the pipeline definition to `Get Pipeline script from SCM`.
          3. Update the section of `Branches to build` to `*/${branch}` as the parameter added above.
          4. Add the following code to the file `Jenkinsfile`.

          {code:groovy}
          pipeline {
              agent {
                  kubernetes {
                      label 'jks-builds'
                      yamlFile 'path/to/podTemplate.yaml'
                  }
              }

              stages {
                  stage('test') {
                      steps {
                           echo "test"
                      }
                  }
              }
          }
          {code}

          with the above reproducing steps you will get the following failed messages:

          {code:java}
          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${branch}:refs/remotes/origin/${branch} --prune" returned status code 128:
          stdout:
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}
          {code}

          however, it works if you remove the directive of `yamlFile` or using the raw yaml string instead.
          Carlos Sanchez made changes -
          Link New: This issue is related to JENKINS-53472 [ JENKINS-53472 ]
          Carlos Sanchez made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-56943 [ JENKINS-56943 ]
          Jesse Glick made changes -
          Assignee Original: Carlos Sanchez [ csanchez ]
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            jubel jubel han
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: