如何 print/debug 包含在 GitLab CI 中的所有作业?
How to print/debug all jobs of includes in GitLab CI?
在 Gitlab CI 中,可以在 .gitlab-ci.yml
文件中包含一个或多个文件。
甚至可以嵌套这些包含。
参见 https://docs.gitlab.com/ee/ci/yaml/includes.html#using-nested-includes。
如何一次性查看生成的 CI 文件?
现在,当我调试一个 CI 循环时,我打开每个包含文件并
自己组合生成的文件结构。必须有更好的方法。
例子
https://company.com/autodevops-template.yml的内容:
variables:
POSTGRES_USER: user
POSTGRES_PASSWORD: testing_password
POSTGRES_DB: $CI_ENVIRONMENT_SLUG
production:
stage: production
script:
- install_dependencies
- deploy
environment:
name: production
url: https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
only:
- master
.gitlab-ci.yml的内容:
include: 'https://company.com/autodevops-template.yml'
image: alpine:latest
variables:
POSTGRES_USER: root
POSTGRES_PASSWORD: secure_password
stages:
- build
- test
- production
production:
environment:
url: https://example.com
这应该会产生以下文件结构:
image: alpine:latest
variables:
POSTGRES_USER: root
POSTGRES_PASSWORD: secure_password
POSTGRES_DB: $CI_ENVIRONMENT_SLUG
stages:
- build
- test
- production
production:
stage: production
script:
- install_dependencies
- deploy
environment:
name: production
url: https://example.com
only:
- master
→ 我怎样才能在某处看到这个输出?
环境
- 自托管 GitLab 13.9.1
当我继续寻找解决方案时,我读到了今年 GitLab 13.8 版中发布的“管道编辑器”。原来我要找的功能是几天前添加到这个编辑器中的:
版本 13.9.0 (2021-02-22)“查看 CI/CD 配置的扩展版本”→ 有关功能描述和介绍视频,请参阅 Release Notes。
To view the fully expanded CI/CD configuration as one combined file,
go to the pipeline editor’s »View merged YAML« tab. This tab displays an
expanded configuration where:
- Configuration imported with include is copied into the view.
- Jobs that use extends display with the extended configuration merged into the job.
- YAML anchors are replaced with the linked configuration
用法:打开项目 → 模块 »CI / CD« → 子模块 »Editor« → Tab »View merged YAML«
在 Gitlab CI 中,可以在 .gitlab-ci.yml
文件中包含一个或多个文件。
甚至可以嵌套这些包含。
参见 https://docs.gitlab.com/ee/ci/yaml/includes.html#using-nested-includes。
如何一次性查看生成的 CI 文件?
现在,当我调试一个 CI 循环时,我打开每个包含文件并 自己组合生成的文件结构。必须有更好的方法。
例子
https://company.com/autodevops-template.yml的内容:
variables:
POSTGRES_USER: user
POSTGRES_PASSWORD: testing_password
POSTGRES_DB: $CI_ENVIRONMENT_SLUG
production:
stage: production
script:
- install_dependencies
- deploy
environment:
name: production
url: https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
only:
- master
.gitlab-ci.yml的内容:
include: 'https://company.com/autodevops-template.yml'
image: alpine:latest
variables:
POSTGRES_USER: root
POSTGRES_PASSWORD: secure_password
stages:
- build
- test
- production
production:
environment:
url: https://example.com
这应该会产生以下文件结构:
image: alpine:latest
variables:
POSTGRES_USER: root
POSTGRES_PASSWORD: secure_password
POSTGRES_DB: $CI_ENVIRONMENT_SLUG
stages:
- build
- test
- production
production:
stage: production
script:
- install_dependencies
- deploy
environment:
name: production
url: https://example.com
only:
- master
→ 我怎样才能在某处看到这个输出?
环境
- 自托管 GitLab 13.9.1
当我继续寻找解决方案时,我读到了今年 GitLab 13.8 版中发布的“管道编辑器”。原来我要找的功能是几天前添加到这个编辑器中的:
版本 13.9.0 (2021-02-22)“查看 CI/CD 配置的扩展版本”→ 有关功能描述和介绍视频,请参阅 Release Notes。
To view the fully expanded CI/CD configuration as one combined file, go to the pipeline editor’s »View merged YAML« tab. This tab displays an expanded configuration where:
- Configuration imported with include is copied into the view.
- Jobs that use extends display with the extended configuration merged into the job.
- YAML anchors are replaced with the linked configuration
用法:打开项目 → 模块 »CI / CD« → 子模块 »Editor« → Tab »View merged YAML«