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

Unable to abort build executing Groovy Postbuild script


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins 2.60, Groovy Postbuild 2.3.1

      It seems to be problematic to abort a build executing a Groovy Postbuild script using the Jenkins UI and even internal Jenkins API.

      I tried to check if the current thread isn't interupted (Thread.currentThread().isInterrupted()), but it's not. The build results (manager.getResult()) is also SUCCESS.

      Sample code:

      int i=0
      while (true) {
        if (++i > 20) {    //to do not create a zombie build :)
          manager.listener.logger.println "Timeout. Aborting..."
        if (Thread.currentThread().isInterrupted()) {
          manager.listener.logger.println "Interrupted. Aborting..."
        manager.listener.logger.println "Not aborted - ${manager.getResult()} - ${Thread.currentThread().isInterrupted()}"

      results in:

      Not aborted - SUCCESS - false
      Not aborted - SUCCESS - false
      Not aborted - SUCCESS - false
      Timeout. Aborting...

      Being unable to abort the build is very problematic for example if the Groovy script is used to call the external service waiting for some operation to finish.

      The mailing list hasn't provied any other possible solution: https://groups.google.com/forum/#!topic/jenkinsci-dev/jsXlO8CLwsI

            Unassigned Unassigned
            emszpak Marcin Zajączkowski
            0 Vote for this issue
            1 Start watching this issue