You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins任务延迟配置咨询:Job A完成后10分钟触发Job B

解决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:

  1. Open Job A's configuration page
  2. Scroll to Post-build Actions, click "Add post-build action" and select "Build other projects"
  3. Enter Job B in the "Projects to build" field
  4. Click the "Advanced" dropdown, find "Delay build", select "Delay by a fixed amount of time", and set it to 10 minutes
  5. Optional: Check "Trigger only if build is stable" if you want Job B to run only when Job A succeeds
  6. 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:

  1. Install the plugin and open Job A's configuration
  2. Add a "Trigger parameterized build on other projects" post-build action
  3. Input Job B as the target project
  4. Click "Advanced", then in the "Build delay" field, enter 600 (since 10 minutes = 600 seconds)
  5. Set your preferred trigger conditions (e.g., "Trigger only if build is successful")
  6. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:43:12