Details
-
Bug
-
Status: Resolved (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
Jenkins 2.89.4
Gerrit Trigger plugin 2.27.5
Description
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.
Code changed in jenkins
User: Allen Wild
Path:
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
http://jenkins-ci.org/commit/gerrit-trigger-plugin/388ee68cc75ba04b10ce19c702af3f7e1dce768c
Log:
JENKINS-49813RunningJobs: Remove extra shouldCancelPatchsetNumber checkAn extra check for !shouldCancelPatchsetNumber after the check for
(!abortBecauseOfTopic && !shouldCancelpatchsetNumber) breaks the "Abort
patch sets with same topic" feature.
It appears that these lines were added inadvertently during
merge conflict resolution in 7455d86c5d0eaf72743094d64e5faa23b1a5bf82.
Removing this extra if block allows for cancelling running jobs when
a new patchset arrives on the same topic.
Signed-off-by: Allen Wild <allenwild93@gmail.com>