Jenkins: settings for Gerrit Trigger problems

匆匆过客 提交于 2019-12-10 20:48:37

问题


I've installed the plugin Gerrit Trigger on Jenkins cos I need to start automatically the building when a developer in the team pushes something on the repository (relative to a specific project). I followed the settings here:

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

The test connection is ok. Anyway when something is pushed the building doesn't "trigger". The only thing I can see is:

Under "Manage Jenkins" -> The connection to Gerrit is down! Check your settings and the Gerrit server.

any idea?

thanks

randomize

BTW I got this:

BTW I got this: Command "git fetch -t git@github.com:somewhere/MyProject.git $GERRIT_REFSPEC" returned status code 128: fatal: Couldn't find remote ref $GERRIT_REFSPEC fatal: The remote end hung up unexpectedly

 ERROR: Could not fetch from any repository
 FATAL: Could not fetch from any repository
 hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1008)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:758)
at hudson.FilePath.act(FilePath.java:740)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1184)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:537)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:425)
at hudson.model.Run.run(Run.java:1376)

回答1:


There is trick described on the Gerrit plugin page:

Normally when you have configured a job to be triggered by Gerrit you can't use the "Build Now" link anymore since your builds are dependent on information from Gerrit, especially if you are using the Git plugin to checkout your code in the workspace.

You can get around this limitation if you for example want to use the same job to build the master branch at some point. If you are using the Git plugin do the following

Add a String parameter called GERRIT_REFSPEC with the default value refs/heads/master

Using this trick will enable you to build, but no results will be sent to Gerrit since tit is not triggered by it.




回答2:


That doesn't work with the Gerrit trigger, because then the variable $GERRIT_REFSPEC isn't set. If you want to manually trigger a changeset from Gerrit, you have to use the "Query and Trigger Gerrit Patches". There you can search for open changes in Gerrit and build them.

You should also notice, that a build is only triggered, if you have pushed the changes to the review branches in Gerrit, e.g. a refs/for/ reference. If you pushed directly to the branches (e. g. refs/heads/master), because you don't want to do code review, the Gerrit trigger doesn't work. You would have to use one of the Gerrit hooks, that calls a URL which starts a build or let the build job poll your Git repository.




回答3:


You Need to start the gerrit server from the jenkin>> gerrit trigger> click on status icon.



来源:https://stackoverflow.com/questions/7582331/jenkins-settings-for-gerrit-trigger-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!