英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论