能否实现一键批量审批多发布部署?30+CD流水线批量审批需求
一键审批多条CD流水线的解决方案
Great question—managing 30+ CD pipelines with individual approvals is definitely a drag, and most modern CI/CD tools have solutions to let you approve all of them in one go. Here’s how to set this up depending on what tool you’re using:
Jenkins
- Use the Batch Task Plugin or Pipeline Aggregator Plugin to group your pipelines under a single approval stage. Create a parent pipeline that holds the approval step, then triggers all 30+ child pipelines once approved.
- Example parent pipeline snippet:
pipeline { agent any stages { stage('Batch Approval') { steps { input message: 'Approve all 30 CD pipelines for deployment?', submitter: 'devops-team' } } stage('Trigger All Pipelines') { steps { // Loop through your pipeline list instead of repeating lines def pipelineJobs = ['Pipeline-Service-1', 'Pipeline-Service-2', ...] pipelineJobs.each { job -> build job: job, wait: false } } } } }
- The loop makes this scalable—just update the
pipelineJobslist with all your pipeline names instead of writing 30+buildcommands.
GitLab CI/CD
- Use parent-child pipelines with a single manual approval job in the parent pipeline. Once approved, the parent triggers all child deployment pipelines at once.
- Example parent
.gitlab-ci.ymlsnippet:
stages: - batch_approval - trigger_deployments approve_all_deploys: stage: batch_approval rules: - if: $CI_COMMIT_BRANCH == 'main' when: manual allow_failure: false script: echo "Batch approval granted for all CD pipelines" # Dynamically generate trigger jobs (scalable for 30+ pipelines) .trigger_template: stage: trigger_deployments needs: [approve_all_deploys] trigger: include: $PIPELINE_FILE trigger-service-1: extends: .trigger_template variables: PIPELINE_FILE: pipelines/deploy-service-1.yml trigger-service-2: extends: .trigger_template variables: PIPELINE_FILE: pipelines/deploy-service-2.yml # Repeat the above block for all your 30+ services
- Using a template (
trigger_template) cuts down on repetition, making it easier to manage as you add more pipelines.
GitHub Actions
- Create a workflow dispatch workflow that requires environment approval, then uses the GitHub API to trigger all your deployment workflows in one batch.
- Example batch approval workflow:
name: Batch Approve & Trigger CD Pipelines on: workflow_dispatch: jobs: batch_approval: runs-on: ubuntu-latest environment: production # Requires manual approval configured in repo settings steps: - name: Trigger all deployment pipelines uses: actions/github-script@v6 with: script: | // List all your deployment workflow files here const deployWorkflows = [ '.github/workflows/deploy-service-1.yml', '.github/workflows/deploy-service-2.yml', // Add all 30+ workflows ]; for (const workflow of deployWorkflows) { await github.rest.actions.createWorkflowDispatch({ owner: context.repo.owner, repo: context.repo.repo, workflow_id: workflow, ref: 'main' }); }
- You’ll need to set up an environment approval rule in your GitHub repo settings for the
productionenvironment to enforce the single approval step.
For Other CI/CD Tools
If you’re using tools like CircleCI, Azure DevOps, or Bitbucket Pipelines, the core approach stays the same: create a central "control" workflow that handles the single approval, then triggers all your deployment pipelines once that approval is granted. Most tools have built-in features for pipeline chaining or batch triggering that you can leverage.
内容的提问来源于stack exchange,提问作者usha chokka
相关产品推荐
相关产品推荐

