When using jenkins for automatic compilation and construction, some tasks may have been blocked due to network or other reasons, causing the project to be unable to perform compilation and construction again. We want to terminate certain tasks when their execution time exceeds a certain value.
Method one (general)
The "build timeout plugin" plugin of jenkins can help us accomplish this task. I am using jenkins-2.7.1, the plug-in is already installed by default, if it is not installed by default, you can search and install it in the plug-in management.
Method 2 (Pipeline)
Jenkins Pipeline provides a lot of steps (steps), which can be combined and nested with each other to easily solve problems such as repeating the steps until successful (retry) and exiting (timeout) if a step takes too long to execute.
pipeline {
agent any
stages {
stage('Deploy') {
steps {
retry(3) {
sh './flakey-deploy.sh'
}
timeout(time: 3, unit: 'MINUTES') {
sh './health-check.sh'
}
}
}
}
}
The "Deploy" stage (stage) repeatedly executes the flakey-deploy.sh script 3 times, and then waits for the health-check.sh script to execute for a maximum of 3 minutes. If the health-check.sh script is not completed within 3 minutes, Pipeline will mark it as failed in the "Deploy" phase.
Embedded type
Embedded types of steps, such as timeout and retry can contain other steps, including timeout and retry.
We can also combine these steps. For example, if we want to retry the deployment task 5 times, but the total time spent cannot exceed 3 minutes.
pipeline {
agent any
stages {
stage('Deploy') {
steps {
timeout(time: 3, unit: 'MINUTES') {
retry(5) {
sh './flakey-deploy.sh'
}
}
}
}
}
}
Series of articles
jenkins automated configuration
Jenkins's tty problem
jenkins reverse proxy configuration
jenkins's java11 issue
Jenkins private key format error problem
jenkins webhooks configuration
jenkins set task timeout⏱ (multiple methods: pictures and texts 🖼)
refer to
- nginx configuration prohibits reverse proxy under a specific path
- nginx configuration prohibits access to the directory or prohibits access to the files in the directory
- nginx cross-domain processing
- takes you in-depth understanding of nginx basic login authentication (including configuration steps)
- Use htpasswd to generate password
- Use openssl to generate password
- Use python to generate password
- your nginx login authentication safe?
- Configure http basic authentication (Basic Auth)
- Centos install htpasswd_Nginx using htpasswd
- takes you in-depth understanding of nginx basic login authentication (including all configuration steps and in-depth analysis)
- takes you in-depth understanding of nginx basic login authentication: use htpasswd to generate password
- takes you in-depth understanding of nginx basic login authentication: use openssl to generate password
- takes you in-depth understanding of nginx basic login authentication: use python to generate password
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。