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

GERRIT_REFSPEC not recognized during scm git checkout - Jenkinsfile declarative with Kubernetes agent

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins: 2.303.1
      Kubernetes plugin: 1.30.1
      Git plugin: 4.8.2
      Gerrit trigger plugin: 2.34.0

      I have a declarative pipeline that uses a kubernetes agent.

      pipeline {

        agent {

          kubernetes {

            yamlFile "file.yml"

             }

          }

        ...

      }

      The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

      During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).

      Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
      Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
      Selected Git installation does not exist. Using Default
      The recommended git tool is: NONE
      using credential gerrit
      > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
      Fetching changes from the remote Git repository
      > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
      Fetching upstream changes from ssh://[gerrit-server]/[project]
      > git --version # timeout=10
      > git --version # 'git version 2.30.2'
      using GIT_SSH to set credentials [gerrit-server]
      > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
      > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^{commit} # timeout=10
      > git rev-parse refs/changes/11/111111/11^{commit} # timeout=10
      Checking out Revision [revision-id] (refs/changes/11/111111/11)
      > git config core.sparsecheckout # timeout=10
      > git checkout -f [revision-id] # timeout=10
      Commit message: "[commit-message]"
      First time build. Skipping changelog.
      Running in Durability level: MAX_SURVIVABILITY
      hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
      stdout:
      stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
      at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
      at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
      at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
      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.impersonate2(ACL.java:449)
      at hudson.security.ACL.impersonate(ACL.java:461)
      at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:829)
      Finished: FAILURE

      I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

      If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.

      agent: { label [physical-node-label] }

      Versions used:

          [JENKINS-66599] GERRIT_REFSPEC not recognized during scm git checkout - Jenkinsfile declarative with Kubernetes agent

          Ciprian Vintea created issue -
          Ciprian Vintea made changes -
          Description Original: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

          {{    }}}

          {{  }}}

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}{{Triggered by Gerrit: https://[gerrit-server]
          Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
          Selected Git installation does not exist. Using Default
          The recommended git tool is: NONE
          using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
          Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
          using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress -- ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
          Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
          Commit message: "[commit-message]"
          First time build. Skipping changelog.
          Running in Durability level: MAX_SURVIVABILITY
          hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
          stdout:
          stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
          Finished: FAILURE}}
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}{{agent { label [physical-node-label] }}}
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          New: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

           

          {{    }}}

          {{  }}}

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
           Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
           Selected Git installation does not exist. Using Default
           The recommended git tool is: NONE
           using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
           Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
           Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
           using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
           Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
           Commit message: "[commit-message]"
           First time build. Skipping changelog.
           Running in Durability level: MAX_SURVIVABILITY
           hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
           stdout:
           stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
           Finished: FAILURE
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}agent: \{ label [physical-node-label] }
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          Ciprian Vintea made changes -
          Description Original: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

           

          {{    }}}

          {{  }}}

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
           Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
           Selected Git installation does not exist. Using Default
           The recommended git tool is: NONE
           using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
           Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
           Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
           using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
           Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
           Commit message: "[commit-message]"
           First time build. Skipping changelog.
           Running in Durability level: MAX_SURVIVABILITY
           hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
           stdout:
           stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
           Finished: FAILURE
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}agent: \{ label [physical-node-label] }
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          New: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

                 }

              }

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
           Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
           Selected Git installation does not exist. Using Default
           The recommended git tool is: NONE
           using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
           Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
           Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
           using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
           Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
           Commit message: "[commit-message]"
           First time build. Skipping changelog.
           Running in Durability level: MAX_SURVIVABILITY
           hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
           stdout:
           stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
           Finished: FAILURE
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}agent: { label [physical-node-label] }
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          Ciprian Vintea made changes -
          Description Original: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

                 }

              }

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
           Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
           Selected Git installation does not exist. Using Default
           The recommended git tool is: NONE
           using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
           Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
           Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
           using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
           Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
           Commit message: "[commit-message]"
           First time build. Skipping changelog.
           Running in Durability level: MAX_SURVIVABILITY
           hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
           stdout:
           stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
           Finished: FAILURE
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}agent: { label [physical-node-label] }
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          New: I have a declarative pipeline that uses a kubernetes agent.
          {quote}{{pipeline {}}

          {{  agent {}}

          {{    kubernetes {}}

          {{      yamlFile "file.yml"}}

                 }

              }

          {{  ...}}

          {{}}}
          {quote}
          The pipeline is started by a Gerrit trigger, the GERRIT_REFSPEC parameter is provided by this trigger.

          During scm git checkout a first git fetch is made successfully (GERRIT_RESPEC is recognized), the second one fails (GERRIT_RESPEC is NOT recognized).
          {quote}Triggered by Gerrit: [https://[gerrit-server|https://[gerrit-server/]]
           Checking out git ssh://[gerrit-server]/[project] into [workspace] to read Jenkinsfile
           Selected Git installation does not exist. Using Default
           The recommended git tool is: NONE
           using credential gerrit
           > git rev-parse --resolve-git-dir [workspace]/.git # timeout=10
           Fetching changes from the remote Git repository
           > git config remote.origin.url ssh://[gerrit-server]/[project] # timeout=10
           Fetching upstream changes from ssh://[gerrit-server]/[project]
           > git --version # timeout=10
           > git --version # 'git version 2.30.2'
           using GIT_SSH to set credentials [gerrit-server]
           > git fetch --tags --force --progress – ssh://[gerrit-server]/[project] refs/changes/11/111111/11:refs/changes/11/111111/11 # timeout=10
           > git rev-parse refs/remotes/origin/refs/changes/11/111111/11^\{commit} # timeout=10
           > git rev-parse refs/changes/11/111111/11^\{commit} # timeout=10
           Checking out Revision [revision-id] (refs/changes/11/111111/11)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f [revision-id] # timeout=10
           Commit message: "[commit-message]"
           First time build. Skipping changelog.
           Running in Durability level: MAX_SURVIVABILITY
           hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/$GERRIT_REFSPEC:refs/remotes/origin/$GERRIT_REFSPEC" returned status code 128:
           stdout:
           stderr: fatal: couldn't find remote ref refs/heads/$GERRIT_REFSPEC
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
           at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
           at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
           at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
           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.impersonate2(ACL.java:449)
           at hudson.security.ACL.impersonate(ACL.java:461)
           at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
           at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
           Finished: FAILURE
          {quote}
          I've seen some other suggestions to disable Lightweight checkout option, but this is already disabled in my case. Also Preserve second fetch during checkout is unchecked.

          *If I use a node label (node being manually added to Jenkins) instead of kubernetes agent the scm git checkout phase succeeds.*
          {quote}agent: \{ label [physical-node-label] }
          {quote}
          Versions used:
           * Jenkins: 2.303.1
           * [Kubernetes plugin|https://plugins.jenkins.io/kubernetes/]: 1.30.1
           * [Git plugin|https://plugins.jenkins.io/git/]: 4.8.2
           * [Gerrit trigger plugin|https://plugins.jenkins.io/gerrit-trigger/]: 2.34.0
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Ciprian Vintea made changes -
          Component/s New: kubernetes-plugin [ 20639 ]
          Ciprian Vintea made changes -
          Priority Original: Major [ 3 ] New: Minor [ 4 ]

            Unassigned Unassigned
            ciprian_vintea Ciprian Vintea
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: