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

fix Executor.interrupt(ABORTED) to let Groovy script cancel a build

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • core, groovy-plugin
    • None

      It is currently not possible to cancel an ongoing build from a Groovy script.

      The feature is exposed in the UI where the user can cancel an ongoing build. This marks the build as ABORTED and stops the build immediately without processing any more build actions.

      Currently it is only possible from a Groovy script to either (1) interrupt the executor (but that marks the jobs a failed despite the arguments) or (2) mark a job aborted (but all build actions a processed).

      (1)
      build.getExecutor().interrupt(Result.ABORTED)

      1. This will mark the build failed, even if the API suggests something different.

      (2)
      build = Thread.currentThread().executable
      build.setResult(Result.ABORTED)

            ndeloof Nicolas De Loof
            dthomas Dirk Thomas
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: