本文介绍了在Gerrit项目中编辑project.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Gerrit项目中添加一个已验证"标签,以允许Jenkins验证代码是否已构建并通过其测试等等.

I want to add a "verified" label to my Gerrit project to allow Jenkins to verify that the code builds and passes its tests and so on.

我知道我需要向project.config添加一个部分,如下所示:

I know I need to add a section to project.config as below:

[label "Verified"]
       function = MaxWithBlock
       value = -1 Fails
       value =  0 No score
       value = +1 Verified

但是,如何访问该文件进行编辑?

However, how do I get to that file to edit it?

推荐答案

项目设置保存在项目的Git存储库中.您可以通过从Gerrit克隆项目,进行更改,提交并推回Gerrit来对其进行编辑.

The project settings are kept in the Git repository for the project. You can edit them by cloning the project from Gerrit, making the change, committing and pushing back to Gerrit.

您可以对任何项目执行此操作,但是,如果您希望它可以被所有项目继承,则可以使用All-Projects作为项目.

You can do this for any project, but if you want it to be inherited by all your projects, which you probably do, use All-Projects as the project.

mkdir gtproj
cd gtproj
git init
git remote add origin ssh://<USER>@<GERRITHOST>:29418/<PROJECT>
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout meta/config

然后,更改project.config文件,该文件现在位于当前目录中.

Then, make the change to the project.config file which will now be in the current directory.

现在,提交更改,然后返回到Gerrit存储库:

Now, commit the change, and push back to the Gerrit repo:

git commit -a -m "Added label - Verified"
git push origin meta/config:meta/config

就是这样.

如果要测试,请执行以下操作:假设您实际上是在添加已验证"标签,则可以检查它是否正常工作.首先,确保All-Projectsrefs/heads/*部分(或上面更改的任何项目)都为相关组设置了Label-Verified -1/+ 1.这样,列出的组即可进行验证.

If you want to test it: assuming you were actually adding the Verified label, you can check it is working like this. First, make sure the refs/heads/* section of All-Projects (or whichever project you changed above) has Label-Verified -1/+1 set for the relevant groups. This allows the listed groups to verify.

现在,假设您有一个名为MyProject的项目和一个补丁集引用(例如1,1)来进行验证:

Now, assuming you have a project called MyProject and a patchset reference, say 1,1, to verify:

ssh -p 29418 user@host gerrit review --project MyProject --message "'I just verified this patchset'" --verified +1 1,1

这应该立即或多或少返回.现在,您应该在Gerrit网络用户界面中看到您刚刚通过SSH登录的用户对该修补程序留下了+1验证通过的审查.

This should return more or less immediately. You should now see in the Gerrit web UI that the user you just logged in as over SSH has left a +1 verified review on that patch.

信用:源自此博客帖子.

这篇关于在Gerrit项目中编辑project.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 18:56