如何在Gitlab中为非主分支的web接口制作管道?(运行管道按钮)



问题:我有两份工作正在筹备中,我只想由";运行管道";按钮我需要为任何分支机构运行此作业。但当我选择任何非主分支时,gitlab会向我显示";无法运行管道。此管道没有阶段/作业">

首先,我配置了没有"rules"关键字但只有"only"关键字的作业:

only:
refs:
- api
- web

我必须做些什么才能使手动触发的管道运行?

我的最新CI:

stages:
- test
- publish

.run_branch_from_gui:
only:
- branches
- tags
except:
- master
when: manual
compile_and_test_branch_manually:
stage: publish
extends:
- .run_branch_from_gui
script: "echo 'test'"
publish_docker_image_branch_manually:
extends:
- .run_branch_from_gui
image: $DOCKER_IMAGE
dependencies:
- compile_and_test_branch_manually
stage: publish
script: "echo 'publish'"

我也试过:

rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: manual
allow_failure: false

但没有效果:仍然有">管道无法运行。此管道没有阶段/作业";当我点击";运行管道";按钮

在不了解完整管道的情况下,我建议您使用规则,并检查$CI_PIPELINE_SOURCE是否为web(此处描述了此变量的可能值)。只有在手动触发时,才会运行作业。

rules:
- if: '$CI_PIPELINE_SOURCE == "web"'

最新更新