In a declarative pipeline's Jenkinsfile it is possible to add a timeout 
option both global as well as override it per stage. E.g.: 

stage ("SonarQube analysis") {
  options {
    timeout(time: 5, unit: 'MINUTES')
  }


  steps {
    script {
      STAGE_NAME = "SonarQube analysis"


      withSonarQubeEnv('SonarQube') {
        sh "../../../sonar-scanner/bin/sonar-scanner"
      }


      // Check whether coverage threshold is met, otherwise fail the job.
      def qualitygate = waitForQualityGate()
      if (qualitygate.status != "OK") {
        slackSend (
          color: '#F01717',
          message: "*$JOB_NAME*: <$BUILD_URL|Build #$BUILD_NUMBER>, 
'$STAGE_NAME' stage failed."
        )
        error "Pipeline aborted due to quality gate coverage failure: 
${qualitygate.status}"
      }
    }
  }
}


Is it possible to make some action in case the timeout was reached? to 
detect it somehow?
In case of a timeout I would like to send a Slack notification.

Right now what happens is that the scanning reached 5 minutes and thus 
never entered the if statement; in which case there is "silent failure".

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/20346cd1-b31b-46e8-8c74-c290e0bb4cd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to