How to add a timeout step to Jenkins Pipeline

£可爱£侵袭症+ 提交于 2019-11-27 20:20:50
StephenKing

You can use the timeout step:

timeout(20) {
  node {
    sh 'foo'
  }
}

If you need a different TimeUnit than MINUTES, you can supply the unit argument:

timeout(time: 20, unit: 'SECONDS') {

EDIT Aug 2018: Nowadays with the more common declarative pipelines (easily recognized by the top-level pipeline construct), timeouts can also be specified using options on different levels (per overall pipeline or per stage):

pipeline {
  options {
      timeout(time: 1, unit: 'HOURS') 
  }
  stages { .. }
  // ..
}

Still, if you want to apply a timeout to a single step in a declarative pipeline, it can be used as described above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!