java Jenkins:Gerrit Trigger 问题的设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7582331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 20:35:25  来源:igfitidea点击:

Jenkins: settings for Gerrit Trigger problems

javajenkinsgerrit

提问by Randomize

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:

我已经在 J​​enkins 上安装了 Gerrit Trigger 插件,因为当团队中的开发人员在存储库上推送某些内容(相对于特定项目)时,我需要自动开始构建。我遵循了这里的设置:

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

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.

在“管理 Jenkins”下 -> 与 Gerrit 的连接已断开!检查您的设置和 Gerrit 服务器。

any idea?

任何的想法?

thanks

谢谢

randomize

随机化

BTW I got this:

顺便说一句,我得到了这个:

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

顺便说一句,我得到了这个:命令“git fetch -t [email protected]:somewhere/MyProject.git $GERRIT_REFSPEC”返回状态代码 128:fatal:找不到远程引用 $GERRIT_REFSPEC 致命:远程端意外挂断

 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.invoke(GitSCM.java:1008)
at hudson.plugins.git.GitSCM.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)

回答by Wernight

There is trick described on the Gerrit plugin page:

Gerrit插件页面上描述了一个技巧:

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.

通常,当您将作业配置为由 Gerrit 触发时,您不能再使用“立即构建”链接,因为您的构建依赖于来自 Gerrit 的信息,尤其是当您使用 Git 插件在工作区中检出代码时。

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

例如,如果您想在某个时候使用相同的作业来构建主分支,则可以绕过此限制。如果您使用的是 Git 插件,请执行以下操作

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

添加一个GERRIT_REFSPEC使用默认值调用的字符串参数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.

使用此技巧将使您能够构建,但不会将任何结果发送到 Gerrit,因为它不会触发山雀。

回答by dunni

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.

这不适用于 Gerrit 触发器,因为没有设置变量 $GERRIT_REFSPEC。如果要从 Gerrit 手动触发变更集,则必须使用“查询和触发 Gerrit 补丁”。您可以在那里搜索 Gerrit 中的开放更改并构建它们。

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.

您还应该注意到,只有在您将更改推送到 Gerrit 中的分支时才会触发构建,例如 refs/for/reference。如果你直接推送到分支(例如 refs/heads/master),因为你不想做代码,Gerrit 触发器不起作用。您必须使用 Gerrit 钩子之一,它调用一个 URL 来启动构建或让构建作业轮询您的 Git 存储库。

回答by Rahul Rox

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

您需要从 jenkin>>gerrit trigger> 单击状态图标启动 gerrit 服务器。