-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Jenkins 2.89.4
Gerrit Trigger plugin 2.27.5
I want to abort a build if a new patchset is added to a change (usually in a different repo/project) with the same topic name. This appears to be exactly the point of the feature which was added in https://github.com/jenkinsci/gerrit-trigger-plugin/pull/326
However, enabling "Abort patch sets with same topic" isn't actually aborting old builds.
Setup (on a clean Jenkins installation with no extraneous plugins or jobs)
- Create a job triggered by the Patchset Created Gerrit event, with at least two different projects
- Upload a change for review in project1 and project2 on Gerrit. Set them to have the same Topic (ignore the first round of builds; let them finish or abort manually)
- Push a new patchset to the project1 change
- Push a new patchset to the project2 change
Expected Result:
- Step 3 should start a new build
- Step 4 should start a new build and abort the build from Step 3
Actual Result:
- The old build is not aborted in Step 4
I did some debugging on this today and think I already found the problem: https://github.com/jenkinsci/gerrit-trigger-plugin/blob/gerrit-trigger-2.27.5/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java#L2287
In RunningJobs.scheduled() there's an extra if (!shouldCancelPatchsetNumber) block right after the if (!abortBecauseOfTopic && !shouldCancelPatchsetNumber). The result is that abortBecauseOfTopic essentially gets ignore.
If I remove those 3 lines, then the feature works as I'd expect. The offending code was added in "Fix the deadlock in RunningJobs". My guess is that it was introduced accidentally as part of merge conflict resolution.