Jenkins任务延迟配置咨询:Job A完成后10分钟触发Job B
Hey there! Let's sort out your Jenkins delay issue step by step. First, let's clear up the confusion around the Period功能 you mentioned: Jenkins' "Periodic Build" is designed to trigger jobs on a fixed schedule (like daily at 2 AM), not to add a delay between dependent jobs. That's why you weren't seeing any effect when using it—totally normal!
Here are several practical solutions to make Job B start 10 minutes after Job A finishes:
方案1:用「Build Delay Plugin」(最简单直观)
If you haven't already, install this plugin via Jenkins' Plugin Manager. Then follow these steps:
- Open Job A's configuration page
- Scroll to Post-build Actions, click "Add post-build action" and select "Build other projects"
- Enter
Job Bin the "Projects to build" field - Click the "Advanced" dropdown, find "Delay build", select "Delay by a fixed amount of time", and set it to
10 minutes - Optional: Check "Trigger only if build is stable" if you want Job B to run only when Job A succeeds
- Save your configuration
Now Job A will automatically trigger Job B after a 10-minute delay once it finishes.
方案2:用「Parameterized Trigger Plugin」(更灵活的参数化触发)
This plugin lets you add delays along with custom parameters:
- Install the plugin and open Job A's configuration
- Add a "Trigger parameterized build on other projects" post-build action
- Input
Job Bas the target project - Click "Advanced", then in the "Build delay" field, enter
600(since 10 minutes = 600 seconds) - Set your preferred trigger conditions (e.g., "Trigger only if build is successful")
- Save the settings
方案3:用Jenkins Pipeline脚本(最适合复杂 workflows)
If you're using Pipeline for your builds, you can directly control the timing in your script:
pipeline { agent any stages { stage('Build Binary') { steps { // Your binary build logic goes here echo "Compiling binary file..." } } } post { success { // Trigger Job A and wait for it to finish build job: 'Job A', wait: true // Wait 10 minutes before triggering Job B sleep time: 10, unit: 'MINUTES' // Start Job B build job: 'Job B' } } }
This script ensures Job A completes first, waits 10 minutes, then launches Job B—perfect for end-to-end control.
方案4:无插件脚本触发(适合不想安装插件的场景)
You can use a shell/batch script in Job A's post-build actions to trigger Job B after a delay:
- For Linux/macOS (Execute shell):
# Wait 10 minutes sleep 600 # Trigger Job B via Jenkins API (replace placeholders with your details) curl -X POST http://your-jenkins-url/job/Job%20B/build --user your-username:your-api-token
- For Windows (Execute Windows batch command):
:: Wait 10 minutes (600 seconds) timeout /t 600 /nobreak :: Trigger Job B via Jenkins API (replace placeholders) curl -X POST http://your-jenkins-url/job/Job%20B/build --user your-username:your-api-token
Note: Make sure your Jenkins instance allows API access and you have the necessary permissions.
内容的提问来源于stack exchange,提问作者Sam

