Timeout on a Build Step of Jenkins

If you are using Jenkins pipeline, and the newer declarative style (has a top level pipeline { element) then there is a timeout option that can be used for the overall job, or on individual stages:

pipeline {
    agent any

    options {
        timeout(time: 1, unit: 'HOURS')   // timeout on whole pipeline job
    }

    stages {
        stage('Example') {
          options {
              timeout(time: 1, unit: 'HOURS')   // timeout on this stage
          }
          steps {
              echo 'Hello World'
          }
        }
    }
}

Docs: https://jenkins.io/doc/book/pipeline/syntax/#options

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)