API CI Lint docs unclear on support for "extends" for merged YAML
Problem to solve
#258843 (closed) says that extends is not yet supported for merged YAML configuration, but it seems it already is.
The documentation at https://docs.gitlab.com/ee/api/lint.html#yaml-expansion says
The CI lint returns an expanded version of the configuration. The expansion does not work for CI configuration added with include: local, or with extends:.
This example from the blog post at https://about.gitlab.com/blog/2021/04/21/devops-workflows-json-format-jq-ci-cd-lint/ works fine:
.job-tmpl:
image: alpine:latest
variables:
BUILD_TYPE: "Debug"
script:
- echo "Hello from GitLab 🦊"
test-extends-stage:
extends: .job-tmpl
test-extends-prod:
extends: .job-tmpl
variables:
BUILD_TYPE: "Release"
script:
- echo "Hello from GitLab 🦊🌈"
$ jq --null-input --arg yaml "$(<.gitlab-ci.main.yml)" '.content=$yaml' \
| curl "https://gitlab.com/api/v4/ci/lint?include_merged_yaml=true" \
--header 'Content-Type: application/json' --data @- \
| jq --raw-output '.merged_yaml'
---
".job-tmpl":
image: alpine:latest
variables:
BUILD_TYPE: Debug
script:
- "echo \"Hello from GitLab \U0001F98A\""
test-extends-stage:
image: alpine:latest
variables:
BUILD_TYPE: Debug
script:
- "echo \"Hello from GitLab \U0001F98A\""
extends: ".job-tmpl"
test-extends-prod:
image: alpine:latest
variables:
BUILD_TYPE: Release
script:
- "echo \"Hello from GitLab \U0001F98A\U0001F308\""
extends: ".job-tmpl"
Further details
Potentially this was solved with #231352 (closed) though needs engineering / product validation from @matteeyah @dhershkovitch @jreporter
This was originally reported at the jq / CI/CD blog post I wrote a while ago: https://about.gitlab.com/blog/2021/04/21/devops-workflows-json-format-jq-ci-cd-lint/?utm_medium=social&utm_source=linkedin&utm_campaign=blog#comment-5372074958
Proposal
Remove the extends limitation in the API docs or specify what exactly does not work with YAML expansion.
Who can address the issue
Technical writers and engineers.