分支管道的“此管道没有阶段/作业作业”

时间:2021-06-07 12:58:16

标签: gitlab-ci pipeline

鉴于以下 .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 阶段的作业明确设置始终运行规则,但没有骰子。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

根据docs

<块引用>

您必须至少在 .pre 或 .post 之外的一个阶段拥有一份工作。

在上述配置中,除了 .pre 中的作业之外,没有在合并请求事件中添加任何作业,因此根本没有添加作业。