[英]Gitlab CI Lint Api
最近,我一直在尝试使用 bash 访问 Gitlab CI Lint Api 使用 ZF6E58Z95DE709E53FE3 为此,我一直在努力严格遵循Gitlab上的文档。 根据 Gitlab 文档,此片段应返回格式化的 yml:
jq --null-input --arg yaml "$(<example-gitlab-ci.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 | fromjson'
当我将 jq 查询缩短为
jq --raw-output '.merged_yaml'
我收到
"---
\".api_test\":
rules:
- if: $CI_PIPELINE_SOURCE==\"merge_request_event\"
changes:
- src/api/*
deploy:
rules:
- when: manual
allow_failure: true
extends:
- \".api_test\"
script:
- echo \"hello world\"
","includes":[],"jobs":[{"name":"deploy","stage":"test","before_script":[],"script":["echo \"hello world\""],"after_script":[],"tag_list":[],"only":null,"except":null,"environment":null,"when":"on_success","allow_failure":false,"needs":null}],"status":"valid"}
当我让这个代码使用fromjson
选项运行时,我得到一个错误:
jq: error (at <stdin>:0): Invalid numeric literal at line 2, column 0 (while parsing '---
".api_test":
rules:
[...]
我在我的智慧尽头,请帮助我!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.