【发布时间】:2021-06-07 12:58:16
【问题描述】:
鉴于以下.gitlab-ci.yml:
---
stages:
- .pre
- test
- build
compile-build-pipeline:
stage: .pre
script: [...]
artifacts:
paths: [".artifacts/build.yaml"]
lint-source:
stage: .pre
script: [...]
run-tests:
stage: test
rules:
- if: '$CI_COMMIT_BRANCH == "$CI_DEFAULT_BRANCH"'
trigger:
strategy: depend
include:
artifact: .artifacts/tests.yaml
job: "compile-test-pipeline"
needs: ["compile-test-pipeline"]
build-things:
stage: test
rules:
- if: '$CI_COMMIT_BRANCH == "$CI_DEFAULT_BRANCH"'
trigger:
strategy: depend
include:
artifact: .artifacts/build.yaml
job: "compile-build-pipeline"
needs: ["compile-build-pipeline"]
...
配置应始终运行(任何分支,任何来源)。测试和构建作业应该只在默认分支上运行。
但是,没有为合并请求运行任何作业,并且在默认分支以外的分支上手动触发管道会给出错误 No Jobs/Stages for this Pipeline。
我尝试使用rules: [{if: '$CI_PIPELINE_SOURCE'}] 为.pre 阶段中的作业明确设置始终运行规则,但没有骰子。
我做错了什么?
【问题讨论】: