-
Bug
-
Resolution: Fixed
-
Blocker
-
Jenkins 2.387.3
Gerrit Trigger 2.39.0
We rely on the "topic-changed" Gerrit events to query Gerrit for patchsets with the same topic to checkout changes across different repos, and this appears to have stopped working in v2.39.0.
Reverting back to v2.38.1 works again so it seems like a regression in the latest version.
We have confirmed that we see the "topic-changed" events on the Gerrit server's event stream and the patch sets also appear in the "Query and Trigger Gerrit Patches" area when searching for the topic, so this is definitely plugin related.
Using v2.39.0 we also tried enabling these settings, but it had no effect:
- Build Current Patches Only
- Abort manual patch sets
- Abort patch sets with same topic
- Vote patch sets with same topic
Pushing new patchsets would still trigger changes, but they didn't populate the "GERRIT_TOPIC" parameter which is what we rely on for querying Gerrit for the linked patchsets.
Reproduction steps:
Repro Steps
0. ensure gerrit trigger for the Jenkins job configured to trigger a build when the change is rebased.
1. create a change with a topic
2. push the change
3. edit the change and remove the topic
4. rebase the change
Expected:
The gerrit plugin triggers a Jenkins build.
mvn hpi:run with a breakpoint at line 194 of src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java
should show the resulting NPE.
This issue is technically a duplicate of https://issues.jenkins.io/browse/JENKINS-61928, which is caused by the same underlying issue, namely:
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/RunningJobs.java#shouldIgnoreEvent(...)
takes two events as arguments. These events can contain patchSet objects which are null. This assertion is based on the fact that I can step through the code and see a NPE generated at line 194. The NPE throws and causes the build to be aborted.
The following comments address the code at this commit:
commit 2d5d90b48f75b24a50fd93fddfa7a6900fa98c1b (HEAD -> master, origin/master, origin/HEAD)
Merge: 03929e1e c7e26beb
The code accessing the event.patchSet at RunningJobs.java line 194:
boolean shouldCancelPatchsetNumber = policy.isAbortNewPatchsets()
|| Integer.parseInt(runningChangeBasedEvent.getPatchSet().getNumber())
< Integer.parseInt(event.getPatchSet().getNumber());
Clearly does not take into account these values (runningChangeBasedEvent.getPatchSet() and event.getPatchSet()) can be null.