You need to enable JavaScript to run this app. 如何解锁GitLab CI中dev分支下被阻塞的deploy_int_*手动任务?
优惠活动
大模型
产品
解决方案
定价
更多

如何解锁GitLab CI中dev分支下被阻塞的deploy_int_*手动任务?

问题根因

你的配置中,两个备选部署任务deploy_test_alternative、deploy_int_alternative没有显式声明匹配规则,GitLab CI 对未配置rules/only/except的任务有默认过滤逻辑,当dev分支的流水线触发时,同阶段的*_actual部署任务命中了针对dev的规则,导致无规则的备选任务不会被加载到流水线中,也就无法手动触发。

调整方案

给两个备选部署任务显式添加全分支匹配的规则,确保dev分支下也能正常加载这两个任务,修改后的完整配置如下:

image: ubuntu:18.04

stages:
  - test
  - deploy_test
  - deploy_integration

test:
  stage: test
  when: always
  script:
    - echo "Hi test!"

deploy_test_actual:
  stage: deploy_test
  rules:
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "dev"'
      when: manual
    - if: '$CI_COMMIT_BRANCH == "dev"'
      when: manual
  script:
    - echo "Hi!"

deploy_test_alternative:
  stage: deploy_test
  rules:
    - when: manual
  allow_failure: true
  script:
    - echo "Hi!"

deploy_int_actual:
  stage: deploy_integration
  rules:
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "dev"'
      when: manual
    - if: '$CI_COMMIT_BRANCH == "dev"'
      when: manual
  script:
    - echo "Hi!"

deploy_int_alternative:
  stage: deploy_integration
  rules:
    - when: manual
  script:
    - echo "Hi!"

如果需要进一步限制备选任务的触发场景,也可以在rules中添加对应的if条件,比如只在非标签推送的场景下触发,按需调整即可。


内容的提问来源于stack exchange,提问作者AbreQueVoy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.12 08:21:03