The Jenkins Gerrit Verify Status Reporter plugin allows Jenkins to publish test reports to Gerrit instances that are using the Gerrit verify-status plugin.
- Gerrit ver 2.13+
- Jenkins ver 1.625.3+
- Jenkins Gerrit Trigger Plugin ver 2.20.0+
This is a quick start guide on how to quickly install and configure Gerrit and Jenkins so that Jenkins can report job results to Gerrit.
NOTE: This Guide is meant for the impatient hacker who doesn't want to read an endless streams of documentation and the developers who do don't want to write it :)
- Setup database connection info in gerrit.config
[plugin "verify-status"]
dbType = h2
database = /home/joe/gerrit_testsite/db/CiDB
- Copy the verify-status.jar file into the Gerrit $site/plugins directory
- Stop Gerrit
- Run
java -jar gerrit.war init -d $site
to initialize the database
NOTE: If you prefer to run without prompts add the --batch
flag.
- Start Gerrit
- Create a Gerrit user (i.e. 'Jenkins') to allow the jenkins to connect to it.
- Add the 'Jenkins' user to the 'Non-Interactive Users' group.
Gerrit -> People -> List Groups -> Non-Interactive Users
Add 'Jenkins' user to the group
- Configure access controls for the 'Non-Interactive Users' group
Projects -> List -> All-Projects -> Access
Edit
Global Capabilities -> Add Permission -> Save Verification Report -> Add Group
Allow: Non-Interactive Users
Global Capabilities -> Add Permission -> Stream Events -> Add Group
Allow: Non-Interactive Users
Save settings
- Create an http password for the 'Jenkins' user.
Login as the Jenkins user
Settings -> HTTP Password -> Generate Password
- Install the Jenkins Gerrit trigger plugin using the Jenkins plugin manager.
- Install the Jenkins gerrit-verify-status-reporter plugin
- Configure the Gerrit trigger global config to connect to a Gerrit instance.
Jenkins -> Manage Jenkins -> Gerrit Trigger
- Configure it to use the Gerrit Rest API. The config is under the 'Advanced'
setting. Enter the http password from
Setup the Gerrit User
section. - Configure Jenkins Global configuration to enable environment variables.
Jenkins -> Manage Jenkins -> Configure System -> Global properties
Enable Environment variables
Save settings
- Create a new Jenkins job
- Configure the job settings.
- Setup a Gerrit trigger event and set all of the paramters to Human readable
- Add a new patchset created event.
- Add a regular expression trigger event. Make it trigger on 'recheck'.
- Add a 'Post a verification to Gerrit' post-build action.
- Set the Rerun Comment to 'recheck', you can leave the other verification parameters blank.
- Save the job.
Note: The job abstain and value data are automatically determined:
- abstain is true if the Gerrit Trigger is set to SilentMode or any SkipVote parameter is enable.
- value is set to +1 for pass, -1 for fail and 0 for unstable result.
- Login into Gerrit with any user.
- View any patchset.
- Reply to a patchset with a 'recheck' comment (this should auotmatically kick off a jenkins build).
- After Jenkins has completed running the build it will send a verification report to Gerrit.
- The report should now appear on the Gerrit UI (under the Code-Review label).
- Check the Gerrit logs and Jenkins logs to see if there are any errors
- Communication between Gerrit and Jenkins are done using SSH and REST APIs so make sure the security is setup so that one server can communicate with the other.
- Use the ssh gsql command to see if any test results are in the database.