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

build.state.result always SUCCESS in guard block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • build-flow-plugin
    • None
    • Jenkins 1.639

      build.state.result should return FAILURE in the guard block, but always returns SUCCESS.

      Script

      import hudson.model.Result
      
      def run_builds(){
          parallel (
          {
              ignore(FAILURE) {build("Tests/TestSuccess")}
              build("Tests/TestSuccess")
          },
          {
              build("Tests/TestSuccess")
              build("Tests/TestFailure")
          },
      )}
      
      guard {
          run_builds()
      } rescue {
          out.println "Result should be FAILURE but is $build.state.result"
      }
      

      Output console

      guard {
          parallel {
              Schedule job Jenkins internal tests » TestSuccess
              ignore(FAILURE) {
                  Schedule job Jenkins internal tests » TestSuccess
                  Build Jenkins internal tests » TestSuccess #20 started
                  Build Jenkins internal tests » TestSuccess #20 started
                  Jenkins internal tests » TestSuccess #20 completed 
                  Jenkins internal tests » TestSuccess #20 completed 
                  // SUCCESS ignored
              }
              Schedule job Jenkins internal tests » TestFailure
              Schedule job Jenkins internal tests » TestSuccess
              Build Jenkins internal tests » TestFailure #12 started
              Build Jenkins internal tests » TestSuccess #21 started
              Jenkins internal tests » TestFailure #12 completed  : FAILURE
              Jenkins internal tests » TestSuccess #21 completed 
          }
      } rescue {
      Result should be FAILURE but is SUCCESS
      }
      

            Unassigned Unassigned
            martin_stolle Martin Stolle
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: