【发布时间】:2021-04-30 01:45:39
【问题描述】:
我尝试从 .gitlab-ci.yml 文件中注释掉一些行,但管道未能说明 YAML 格式不正确。
下面是我在 GitLab CI-Pipeline UI 中看到的图片。
下面是.gitlab-ci.yml 文件错误。
stages:
- build
- test
# - release
build-demo-commands:
extends: .npm-job
stage: build
script:
- npm run build-demo-prod
include:
- project: 'myproj/gitlab-ci'
ref: '1.2.0'
file: 'templates/npm.gitlab-ci.yml'
# - project: 'myproj/gitlab-ci'
# ref: '1.2.0'
# file: 'templates/Kaniko-npm.gitlab-ci.yml'
我怀疑 CI 管道有一个预处理器,它支持注释语法。
在.gitlab-ci.yml 文件中注释行的正确方法是什么?
寻找答案
-
我发现了这个Add comments to .gitlab-ci.yml,它是两年前合并的。现在我只需要找到说明如何操作的页面!
-
https://docs.gitlab.com/ee/development/code_comments.html - 没有帮助
-
https://docs.gitlab.com/ee/development/cicd/templates.html#template-types-
-
https://docs.gitlab.com/ee/development/cicd/templates.html#explain-the-template-with-comments - 看起来像答案,为什么会抱怨?
-
https://blog.wplauncher.com/add-comments-to-yaml-file/#:~:text=In%20order%20to%20add%20comments,line%20in%20a%20YAML%20file。这表示
#是执行 cmets 的方式。
编辑/更新:
我认为问题在于包含的脚本,而不是添加 cmets。当我删除 cmets 时,仍然出现错误。错误是:
Found errors in your .gitlab-ci.yml:
npm-deploy-snapshot job: chosen stage does not exist; available stages are .pre
build
test
.post
You can also test your .gitlab-ci.yml in CI Lint
所以我现在相信使用哈希 (#) 字符是评论 .gitlab-ci.yml 文件的正确方法。
【问题讨论】:
标签: gitlab-ci