Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49813

Gerrit Trigger "Abort Patchsets with Same Topic" is broken

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: gerrit-trigger-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.89.4
      Gerrit Trigger plugin 2.27.5
    • Similar Issues:

      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)

      1. Create a job triggered by the Patchset Created Gerrit event, with at least two different projects
      2. 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)
      3. Push a new patchset to the project1 change
      4. 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.

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          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-49813 RunningJobs: Remove extra shouldCancelPatchsetNumber check

          An 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>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - 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-49813 RunningJobs: Remove extra shouldCancelPatchsetNumber check An 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>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Robert Sandell
          Path:
          src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
          http://jenkins-ci.org/commit/gerrit-trigger-plugin/a3bf98d1d4342900137a2739f3a7333ecf710898
          Log:
          Merge pull request #356 from aswild/jenkins-49813

          JENKINS-49813 RunningJobs: Remove extra shouldCancelPatchsetNumber check

          Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/1428ff806971...a3bf98d1d434

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/a3bf98d1d4342900137a2739f3a7333ecf710898 Log: Merge pull request #356 from aswild/jenkins-49813 JENKINS-49813 RunningJobs: Remove extra shouldCancelPatchsetNumber check Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/1428ff806971...a3bf98d1d434
          Show
          aswild Allen Wild added a comment - Fix merged in https://github.com/jenkinsci/gerrit-trigger-plugin/pull/356

            People

            • Assignee:
              rsandell rsandell
              Reporter:
              aswild Allen Wild
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: