Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit project.config in a Gerrit project

Tags:

jenkins

gerrit

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.

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?

like image 890
Inductiveload Avatar asked Mar 06 '14 15:03

Inductiveload


People also ask

Where is Gerrit config file?

File etc/gerrit. config.

What are project configuration files?

A build configuration file is a text file with an . xcconfig filename extension that you add to your project. You can create as many build configuration files as you want, and you configure different settings in each one.

What is meta config?

The meta configuration file is an XML file that outlines the attributes of each LSF object, like a blueprint for each object. There can be only one meta configuration file. A sample metadata configuration file is at /opt/cacti/plugins/meta/metadata. conf.


2 Answers

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.

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

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

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

And that's it.


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.

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

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.


Credit: Cribbed from this blog post.

like image 91
Inductiveload Avatar answered Oct 19 '22 09:10

Inductiveload


You can configure your project config in the Gerrit UI.

You should follow the following steps:

  1. Launch your Gerrit UI.
  2. Login as admin.
  3. Go to projects > and click List.
  4. Select your project and click Edit config button.
  5. Paste your content and click save.
like image 43
Gogs Avatar answered Oct 19 '22 07:10

Gogs