I am trying to integrate Gerrit Code Review with Jenkins and I need to get an email names of all Reviewers that are assigned to a change that triggered Jenkins job. I have found this fragment of Gerrit Code Review plugin with all environmental variables listed, but there is nothing about reviewers.
My goal: send email notification about job status (in Jenkins job Post-Actions via email-ext plugin) to change owner, reviewers patchset creators and job owner.
My question is: is there any way of obtaining Gerrit Reviewers emails and parsing them into Jenkins as a variable?
CodePudding user response:
You can use the REST API, like in the following example:
curl --silent --user USER:PASS --request GET https://GERRIT-SERVER/a/changes/CHANGE-NUMBER/reviewers | sed 1d | jq --raw-output '.[].username'
See more info on Gerrit documentation here.