jenkinsci / jenkinsci/git-plugin

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

Open
#3,682 1 comment 0 reactions 0 assignees View on GitHub
component:git-plugin component:kubernetes-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

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:


---
Originally reported by ciprian_vintea, imported from: GERRIT_REFSPEC not recognized during scm git checkout - Jenkinsfile declarative with Kubernetes agent


  • status: Open
  • priority: Minor
  • component(s): git-plugin, kubernetes-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-02

Raw content of original issue

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:



environment

```
Jenkins: 2.303.1

Kubernetes plugin: 1.30.1

Git plugin: 4.8.2

Gerrit trigger plugin: 2.34.0
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.