0

In my setup I want to combine a local git repository with gerrit as code review tool and Jenkins for automatic reviewing purposes. Git and Gerrit are working properly but Jenkins is making some trouble.

What is working so far: I make a commit which appears for review in Gerrit. Jenkins gets triggered to build the affected project with the new changes.

At this point something goes wrong and Jenkins build fails.

Screenshot of the Console Output

Settings of the Jenkins-Project:

  • SCM: git - repository url is correct, refspec set to $GERRIT_REFSPEC, branch specifier set to $GERRIT_BRANCH, build strategy Gerrit Trigger.
  • Build triggers: gerrit event - server settings correct
  • Build: three Maven goals (test, clean install, javadoc)

The goal is that Jenkins checks out the current commit (with new changes), review it and if the changes are merged to the master it should update its own workspace.

Any ideas what went wrong?

Dani_h
  • 5
  • 2

1 Answers1

0

If you want to build the patchset that was just pushed to Gerrit you must set Jenkins like the in the following example:

enter image description here

  • With your settings I now get: Error fetching remote repo 'origin'. And stderr: fatal: Couldn't find remote ref refs/changes/30/1630/1. – Dani_h Nov 30 '17 at 11:36
  • Is you remote named "origin"? Or it is named differently? Check executing "git remote -v" and change the "Name" field accordingly. – Marcelo Ávila de Oliveira Nov 30 '17 at 12:19
  • How have you started this build? Have you pushed a new patchset to Gerri t and the build was trigged automatically or have you built it manually? To use old patchsets to test you need to select the "Retrigger" option in a specific build. – Marcelo Ávila de Oliveira Nov 30 '17 at 13:42
  • At the beginning I pushed a new patchset to Gerrit and the build was triggered. For testing purposes I use the retrigger option within Jenkins. – Dani_h Nov 30 '17 at 16:23
  • Uhm... why Jenkins was not able to fetch refs/changes/30/1630/1 (It's the patchset 1 of the change 1630)? You could try to fetch the change manually (git fetch https://GERRIT-SERVER/a/REPO-FULL-PATH refs/changes/30/1630/1) to try do identify what is happening. – Marcelo Ávila de Oliveira Nov 30 '17 at 17:30
  • I think I found a solution. As repository URL I set the git URL but told him to fetch the current patchset. But this patchset is located in Gerrit, that's why Jenkins couldn't find it. What works for me is to set the repository URL to the Gerrit project workspace. I didn't know that there is stored a complete copy of the git repository, so to reference this adress works as well. – Dani_h Dec 01 '17 at 11:27
  • I didn't understand what you means by "I set the git URL"... but you MUST to set [https://GERRIT-SERVER/a/REPO-FULL-PATH](https://GERRIT-SERVER/a/REPO-FULL-PATH) in the "Repository URL" field. – Marcelo Ávila de Oliveira Dec 01 '17 at 11:49
  • Then that was exactly my fault, I thought I have to reference to git - not to gerrit. Thank you anyway, helped me a lot to understand it. – Dani_h Dec 01 '17 at 13:06