Hi Daniel,
The Gerrit plugin a really nice piece of work that is pathetically documented and poorly integrated with the co-requisite git plugin. It works, but the working config settings are very non-obvious and the integration seems incomplete.
In the sourcecode management section under git, in the advanced/addition behaviours subsection, add strategy for choosing what to build and set it to Gerrit trigger. That is probably the key item that gets your setup at least partially functional.
In the job, configure the Gerrit trigger to watch for patchset created, draft published and change merged. That seems to be all that is actually required in real-world use.
Change your Gerrit trigger branch from plain to path and set it to the branch to build.
I also set a default pair of prarameters in the job, for when someone does a pushbutton build. Se the intended GERRIT_BRANCH to (say) dev, and GERRIT_REFSPEC to (say) refs/heads/dev to get that mode working.
Finally, if you are using promotions or a build step that promotes artifacts, you need to differentiate between Gerrit verification builds and final builds. I add a small block of scripting to check for a non-verification build like so:
if [ ! -z "${GERRIT_EVENT_TYPE}" -a "$GERRIT_EVENT_TYPE" != 'change-merged' ]
then
echo 'You cannot promote a verification build' # >&2
exit 1
fi
The 2-part test is required because there is no consistent means of determining what triggered the build. IMHO, the integration sucks.
{"submitter":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"refUpdate":{"oldRev":"0000000000000000000000000000000000000000","newRev":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","refName":"refs/changes/03/3/2","project":"test2"},"type":"ref-updated","eventCreatedOn":1498585165}
{"uploader":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"patchSet":{"number":2,"revision":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","parents":["bd0d5ae6e6df3cbd6614cbda11e6a7d8632630fb"],"ref":"refs/changes/03/3/2","uploader":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"createdOn":1498585166,"author":{"name":"admin","email":"te...@example.com","username":""},"isDraft":false,"kind":"REWORK","sizeInsertions":1,"sizeDeletions":-1},"change":{"project":"test2","branch":"master","id":"I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb","number":3,"subject":"test","owner":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"url":"http://gerrit.example.com/r/3","commitMessage":"test\n\nChange-Id: I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb\n","status":"NEW"},"project":"test2","refName":"refs/heads/master","changeKey":{"id":"I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb"},"type":"patchset-created","eventCreatedOn":1498585165}
{"submitter":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"refUpdate":{"oldRev":"0000000000000000000000000000000000000000","newRev":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","refName":"refs/changes/03/3/2","project":"test2"},"type":"ref-updated","eventCreatedOn":1498585165}
Thanks for help.
Regards
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/9bcde97b-3b4a-484f-8bb8-960dd44ee84c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{"submitter":{"name":"Administrator","email":"admin@example.com","username":"admin"},"refUpdate":{"oldRev":"0000000000000000000000000000000000000000","newRev":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","refName":"refs/changes/03/3/2","project":"test2"},"type":"ref-updated","eventCreatedOn":1498585165}
{"uploader":{"name":"Administrator","email":"admin@example.com","username":"admin"},"patchSet":{"number":2,"revision":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","parents":["bd0d5ae6e6df3cbd6614cbda11e6a7d8632630fb"],"ref":"refs/changes/03/3/2","uploader":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"createdOn":1498585166,"author":{"name":"admin","email":"test@example.com","username":""},"isDraft":false,"kind":"REWORK","sizeInsertions":1,"sizeDeletions":-1},"change":{"project":"test2","branch":"master","id":"I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb","number":3,"subject":"test","owner":{"name":"Administrator","email":"ad...@example.com","username":"admin"},"url":"http://gerrit.example.com/r/3","commitMessage":"test\n\nChange-Id: I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb\n","status":"NEW"},"project":"test2","refName":"refs/heads/master","changeKey":{"id":"I876e297c0750f08f5ac15c33c46bb3b4d1d86fcb"},"type":"patchset-created","eventCreatedOn":1498585165}
{"submitter":{"name":"Administrator","email":"admin@example.com","username":"admin"},"refUpdate":{"oldRev":"0000000000000000000000000000000000000000","newRev":"395a7383c5958f82a55b7e5129c26cfec27ec4aa","refName":"refs/changes/03/3/2","project":"test2"},"type":"ref-updated","eventCreatedOn":1498585165}
Thanks for help.
Regards