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

Unable to abort build executing Groovy Postbuild script

    XMLWordPrintable

Details

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

    Description

      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..."
          break
        }
      
        if (Thread.currentThread().isInterrupted()) {
          manager.listener.logger.println "Interrupted. Aborting..."
          break
        }
      
        manager.listener.logger.println "Not aborted - ${manager.getResult()} - ${Thread.currentThread().isInterrupted()}"
      
        sleep(1000)
      }

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: