提问人:Cake 提问时间:11/16/2023 最后编辑:Cake 更新时间:11/17/2023 访问量:28
此 GitLab CI 配置无效:此上下文中不允许映射值
This GitLab CI configuration is invalid:mapping values are not allowed in this context
问:
我正在研究 Gitlab CI 模板并有以下文件:.gitlab-ci.yml
include:
- remote: 'https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml'
stages:
- build
- test
build_job:
stage: build
script:
- echo "building application"
test_job:
stage: test
script:
- echo "testing application"
我没有看到任何缩进错误,我在 url 周围使用了“”。gitlab 仍然说:
此 GitLab CI 配置无效: 'https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml': (): 在此上下文中,在第 7 行第 17 列处不允许映射值。
我在这里错过了什么?特别是当第 7 行是空的并且我试图在模板中包含它是一条注释时
答:
1赞
sytech
11/17/2023
#1
问题是您没有使用正确的 URL。GitLab 期望来自 URL 的响应内容只是 YAML 文件。您使用的 URL 包括 gitlab 页面的所有 HTML。
该错误可能会令人困惑,因为它实际上并不是您的 YAML 文件中的问题。当尝试从您作为 YAML 提供的 URL 加载和分析 HTTP 响应内容时,实际上会发生该错误。
要解决此问题,您可以改用原始链接。
此外,此模板还包括使用文件中所需的多个阶段的作业:
include:
- remote: "https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml"
stages:
- build
- test
- environment
- internal
- alpha
- beta
- production
评论