5

I have a GIT repository. When I pushed a GIT change into Gerrit, it triggers a jenkins build and if successful, it merges the code to the GIT repository.

But, Jenkins is building the source from GIT repo always. It is not picking the change pushed into Gerrit.

What settings should I change in Gerrit/Jenkins ?

user691197
  • 927
  • 6
  • 20
  • 38

1 Answers1

3

In the jenkins configuration for the git Source Code Management section, click the advanced button and set your refspec to $GERRIT_REFSPEC which will pick up the change set that was commit.

Mark Fisher
  • 9,838
  • 3
  • 32
  • 38
  • Hi Mark, I still have one more issue. Jenkins build doesn't show the correct change details in the "changes' field of the status page. I tried to add the $GERRIT_SUBJECT_NAME variable in the source code mgmt->Advanced-> name field. But I still see the old changes name. I'm pretty sure that it is building the correct source code, but the 'changes' field is showing the previous change's name. Please suggest me a solution to this too. – user691197 Feb 22 '12 at 19:34
  • I haven't had to configure that, and it works fine here. All I have configured is the "Git" option for Source Code Management, the URL of repository is "git://localhost/my_repo.git", where I have an xinetd.d/git entry to allow the jenkins machine to not have to log into gerrit, but instead access a git-daemon that connects to the gerrit repo. In the advanced tab, I have set the name of the repo to "origin", and the refspec to `$GERRIT_REFSPEC`. I've not had to change anything with the plugin either in jenkins config. – Mark Fisher Feb 23 '12 at 09:46
  • Its working. Only one my first build, it showed the wrong change details. But, from the next build, I'm seeing the correct ones. – user691197 Feb 24 '12 at 09:03
  • 1
    Usually if the Jenkins job is not building from the correct in-review revision, it's because of the "Choosing Strategy" (the *second* "Advanced" button in the Git SCM configuration). That should be set to "Gerrit", not "Git". That is explained in the "Usage with the Git Plugin" section of the [Plugin wiki page](https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger). – Joe Mar 16 '12 at 22:27
  • https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger#GerritTrigger-UsagewiththeGitPlugin – Ritesh Aug 25 '15 at 16:17