Timeout on a Build Step of Jenkins

2020-06-07 06:27发布

In Jenkins, is there a way to give different timeouts to each or selected build step?
Build-time plugin out gives functionality of timeout "Abort the build if it's stuck" on complete project, what I need is to give different timeouts for each step. This way I can make my process more efficient.

10条回答
叼着烟拽天下
2楼-- · 2020-06-07 06:42

If you don't want to use the Jenkins plugin and want to timeout a script or any command then you can use the Linux inbuilt utility "timeout".

timeout -s KILL 1m ./test

The above command will run test executable for 1 minute and if it continues to execute after the timeout then the command will timeout and kill the process by KILL utility.

查看更多
太酷不给撩
3楼-- · 2020-06-07 06:42

Please install Build Timeout plugin for your Jenkins.

Jenkins> Manage Jenkins> Manage Plugins

search for Build Timeout in available tab.. Install it. You would be finding it in Build environment as "Abort the build if it's stuck". Set the Timeout strategy and time. Absolute Deadline Elastic Likely Stuck No Activity

in my case i have used No Activity.

Hope it Helps.

查看更多
老娘就宠你
4楼-- · 2020-06-07 06:44

I think the timeout command from GNU coreutils might be what you want. This is under the assumption that your build steps are scripts.

查看更多
姐就是有狂的资本
5楼-- · 2020-06-07 06:45

Build-timeout Plugin isn't applicable to pipelines. refer to wiki

For pipeline time out, try something like:

timeout(time: 30, unit: 'MINUTES') {
  node {
    sh 'foo'
  }
}

Similar answer from another thread: How to add a timeout step to Jenkins Pipeline

查看更多
倾城 Initia
6楼-- · 2020-06-07 06:46

As of current versions of Jenkins, this can be done. Hit 'Configure', then select the 'Build Environment' tab, and then set your timeout.

Here's an screenshot: enter image description here

查看更多
一夜七次
7楼-- · 2020-06-07 06:47

In pipeline jobs you can wrap your step(s) with timeout as follows:

timeout(time: 5, unit: 'MINUTES') { // steps to execute }

查看更多
登录 后发表回答