Search code examples
gitjenkinsjenkins-pluginsgerrit-trigger

How to download one specific gerrit change set in jenkins git plugin?


Normally we use gerrit trigger plugin in jenkins to download the gerrit changeset.

But in some case, we want to download the specific changesets directly.

For example openstack Change #503032

git pull git://git.openstack.org/openstack/tripleo-quickstart-extras refs/changes/32/503032/2

And set the Refspec to refs/changes/32/503032/2 in git repo like

enter image description here

And enable the Honor refspec on initial clone in Additional behaviours like

enter image description here

But I got error in console log

Fetching upstream changes from git://git.openstack.org/openstack/tripleo-quickstart-extras
 > git fetch --tags --progress git://git.openstack.org/openstack/tripleo-quickstart-extras refs/changes/32/503032/2 --depth=1
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
 > git rev-parse origin/master^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

Any suggestion, we don't want to use the extra command in shell build step.


Solution

  • Set "Branch" to FETCH_HEAD and the specified refspec will be checked out.

    FETCH_HEAD is a temporary ref pointing to the latest fetched refspec, eg. branch, commit. See this question for more information: What does FETCH_HEAD in Git mean?.