ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Validate the `.gitlab-ci.yml` (API) > 原文:[https://docs.gitlab.com/ee/api/lint.html](https://docs.gitlab.com/ee/api/lint.html) # Validate the `.gitlab-ci.yml` (API)[](#validate-the-gitlab-ciyml-api "Permalink") 在 GitLab 8.12 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/5953) . 检查您的`.gitlab-ci.yml`文件是否有效. ``` POST /ci/lint ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `content` | string | yes | the `.gitlab-ci.yaml` content | ``` curl --header "Content-Type: application/json" "https://gitlab.example.com/api/v4/ci/lint" --data '{"content": "{ \"image\": \"ruby:2.6\", \"services\": [\"postgres\"], \"before_script\": [\"bundle install\", \"bundle exec rake db:create\"], \"variables\": {\"DB_NAME\": \"postgres\"}, \"types\": [\"test\", \"deploy\", \"notify\"], \"rspec\": { \"script\": \"rake spec\", \"tags\": [\"ruby\", \"postgres\"], \"only\": [\"branches\"]}}"}' ``` 请务必复制并粘贴`.gitlab-ci.yml`的确切内容,因为 YAML 对于缩进和空格非常挑剔. 响应示例: * 有效内容: ``` { "status": "valid", "errors": [] } ``` * 无效的内容: ``` { "status": "invalid", "errors": [ "variables config should be a hash of key value pairs" ] } ``` * 没有 content 属性: ``` { "error": "content is missing" } ```