feychu
feychu

Reputation: 1364

Jenkins/Gerrit stream events - job triggered on newly created branch

I am using Jenkins in combination with the Git and Gerrit plugins. I would like to trigger a job on Ref Updated. However, I need to understand if the action behind this event is the creation of a new branch. If it is, then I will execute my shell script, otherwise not.

As far as I understood, this info is available in the Gerrit's event json response, but I do not know how to consume this json object via Jenkins in the first place.

Is there a way to achieve this easily via Jenkins (maybe something in the interface I missed)? Or is there another way to monitor the creation of a new branch while still in the Jenkins/Gerrit plugin environment?

Upvotes: 2

Views: 1294

Answers (1)

feychu
feychu

Reputation: 1364

So I just recalled there are a bunch of Gerrit environmental variables which are available to use in the building script,enter image description here

namely these ones. I will just have to check if GERRIT_OLDREV is equal to 0000000000000000000000000000000000000000 and if so, it would mean the branch is newly created (for reference: here). Here is the picture I attached in full size.

Upvotes: 1

Related Questions