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

Loading yamlFile not working with parameterized git branch

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • kubernetes-plugin
    • None

      For a pipeline job, using a declarative syntax with yamlFile, the job fails with the following exception during the yaml file loading step:

      [Pipeline] Start of Pipeline
      [Pipeline] readTrusted
      [Pipeline] End of Pipeline
      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}
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2318)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1905)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:81)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:488)
      	at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:349)
      	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:198)
      	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)
      	at org.jenkinsci.plugins.workflow.multibranch.ReadTrustedStep$Execution.run(ReadTrustedStep.java:101)
      	at org.jenkinsci.plugins.workflow.multibranch.ReadTrustedStep$Execution.run(ReadTrustedStep.java:82)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      	at hudson.security.ACL.impersonate(ACL.java:290)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
       

      ${BRANCH} is a job parameter.

      Note that this is NOT the same as https://issues.jenkins-ci.org/browse/JENKINS-52623, as it only affects the yamlFile usage. Switching to yaml works fine.

      It was also mentioned here: https://issues.jenkins-ci.org/browse/JENKINS-52259?focusedCommentId=344959&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-344959

          [JENKINS-56943] Loading yamlFile not working with parameterized git branch

          Jesse Glick added a comment -

          ${BRANCH} is a job parameter.

          Passing Git branches as a build parameter is not supported by the readTrusted step used internally here. Either use a multibranch project, or inline the YAML into the Jenkinsfile, or switch to Scripted syntax and use readFile to load YAML from an actual checkout (presumably preceding the pod used for the main build).

          Jesse Glick added a comment - ${BRANCH } is a job parameter. Passing Git branches as a build parameter is not supported by the readTrusted step used internally here. Either use a multibranch project, or inline the YAML into the Jenkinsfile , or switch to Scripted syntax and use readFile to load YAML from an actual checkout (presumably preceding the pod used for the main build).

            Unassigned Unassigned
            ungborib Touch Ungboriboonpisal
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: