stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC
Asked Answered
U

4

10

Before anyone guns me down..I have looked at all the messages that has this error but they seem to manifest from a different problem,I couldn't get any substantial information. Following are the errors I'm running into in the git polling log...

  1. I don't have a clue regarding error #1,please provide inputs

  2. For this,I read on other questions that $GERRIT_REFSPEC gets filled in dynamically when there is a gerrit trigger but i don't understand why I keep seeing this in the git poll log. How can I fix this ?


Error messages:

  1. ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway

  2. hudson.plugins.git.GitException: Command "/usr/bin/git fetch -t ssh://company.com:29418/platform/vendor/proprietary/mla.git $GERRIT_REFSPEC" returned status code 128: stdout: stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC

Unnumbered answered 27/12, 2012 at 4:35 Comment(1)
looks like $GERRIT_REFSPEC isn't definedHarriott
M
14
  • Go to the Job's Configure page and search to check This build is parameterized box.
  • Then set Name to GERRIT_REFSPEC
  • and Default value to refs/heads/master.

It took me some time to search for how to add this string parameter mentioned in the Gerrit Trigger plugin manual. I use Jenkins 1.567 with Gerrit Trigger 2.11.1.

Memorabilia answered 12/6, 2014 at 12:15 Comment(3)
you need to specify to add STRING parameterInspect
I have specified that this is string parameter - see the last part: "It took me some time to search for how to add this STRING parameter..."Memorabilia
Add this issue after upgrading to Jenkins 2.1 (from 1.581). This fixed my problemCorettacorette
D
8

As of May 2016, this error may be result of fix for SECURITY-170 introduced in Jenkins 2.3 or 1.651.2.

From wiki:

In a May 2016 security advisory, a vulnerability was announced (SECURITY-170 / CVE-2016-3721) whereby attackers could potentially exploit the fact that certain Jenkins plugins allow the definition of arbitrary build parameters — which are in turn injected into the build envirionment.

The fix for this issue — which was first included in Jenkins versions 1.651.2 and Jenkins 2.3 — means that only build parameters that have been explicitly defined in a job's configuration will be available by default at build time. Any other arbitrary parameters added to a build by plugins will not be available by default.

As there are a number of plugins that rely on the behaviour in older Jenkins versions, upgrading to 1.651.2 or 2.3 means that certain build behaviours may be broken.

One of the affected plugins is the Gerrit Trigger. The issue you should watch for updates is here.

However, please note that the Rado's solution to definine the GERRIT_REFSPEC parameter manually in build config can solve this problem temporarily if you build only one branch from Gerrit.


A workaround is available by adding the following JAVA_ARGS to /etc/default/jenkins on ubuntu

JAVA_ARGS="$JAVA_ARGS -Dhudson.model.ParametersAction.keepUndefinedParameters=true"

You could also add which variables should be allowed

JAVA_ARGS="$JAVA_ARGS -Dhudson.model.ParametersAction.safeParameters=GERRIT_REFSPEC,GERRIT_BRANCH
Dore answered 15/5, 2016 at 16:11 Comment(3)
I hit this problem exactly after upgrading to Jenkins 2.4........all gerrit trigger builds are broken this way.Flense
I followed the following link and added a startup parameter -Dhudson.model.ParametersAction.keepUndefinedParameterstemporarily=true to jenkins.xml as my Jenkins is for internal use only: wiki.jenkins-ci.org/display/SECURITY/…Flense
I added the parameter as well. Still no GERRIT_ variables injected into the jobsMamiemamma
B
2

Looks like you ran a Jenkins Gerrit Trigger build manually? The trigger page says,

Using "Build Now"
[..]
Add a String parameter called GERRIT_REFSPEC with the default value refs/heads/master

https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger

Bridal answered 22/2, 2013 at 22:24 Comment(0)
D
-3

After solving this issue if Jenkins is still not pulling the latest code commit(un-merged) then, need to Add Additional Behaviours -> Strategy for choosing what to build -> Gerrit Trigger

Reference: Thanks to Fabian

enter image description here

Declarant answered 16/11, 2016 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.