这个 GitLab CI 配置无效: jobs:windows job:artifacts 部分的 config 包含未知的键: rules

huangapple go评论76阅读模式
英文:

This GitLab CI configuration is invalid: jobs:windows job:artifacts config contains unknown keys: rules

问题

这是我的当前GitLab CI,可以正常工作且没有错误:

stages:
  - build

windows job:
  image: 
  stage: build

  tags:
    - "Windows"

  script:
    - 

  artifacts:
    paths:
      - ./Debug/*.exe
      - ./Debug/*.pdb

我尝试添加一个规则,仅当分支为“release”时才运行artifacts:


artifacts:
  rules:
    - if: '$CI_COMMIT_BRANCH == "release"'
  paths:
    - ./Debug/*.exe
    - ./Debug/*.pdb

但GitLab报告说:

这个GitLab CI配置无效:jobs:windows job:artifacts配置包含未知的键:rules。

英文:

Does anyone know how to solve my problem?

That is my current GitLab CI, which works without an error:

stages:
  - build


windows job:
  image: 
  stage: build

  tags:
    - "Windows"

  script:
    - 

  artifacts:
    paths:
      - ./Debug/*.exe
      - ./Debug/*.pdb

And I tried to add a rule that artifacts only runs if the branch is “release”:


  artifacts:
    rules:
      - if: '$CI_COMMIT_BRANCH == "release"'
    paths:
      - ./Debug/*.exe
      - ./Debug/*.pdb

But GitLab said:

> This GitLab CI configuration is invalid: jobs:windows job:artifacts config contains unknown keys: rules.

答案1

得分: 1

artifacts 没有 artifacts:rules 关键字。

rules 在“job”级别,或 trigger,或 workflow

一个解决方法是复制作业:

  • 当分支不是 release 时执行一个带有 artifact 部分的作业
  • 当分支 release 时执行一个没有 artifact 部分的作业。
英文:

artifacts does not have an artifacts:rules keyword.

rules is at the "job" level or trigger, or workflow

A workaround would be to duplicate the job:

  • one job executed when the branch is not release, with an artifact section

  • one job executed when the branch is release, without any artifacts section.

huangapple
  • 本文由 发表于 2023年3月31日 17:42:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897018.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定