2017-09-10 17:25:29 +05:30
|
|
|
# Validate the .gitlab-ci.yml (API)
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
> [Introduced][ce-5953] in GitLab 8.12.
|
|
|
|
|
2019-05-18 00:54:41 +05:30
|
|
|
Checks if your `.gitlab-ci.yml` file is valid.
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
```
|
2018-03-17 18:26:18 +05:30
|
|
|
POST /lint
|
2016-09-29 09:46:39 +05:30
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| ---------- | ------- | -------- | -------- |
|
|
|
|
| `content` | string | yes | the .gitlab-ci.yaml content|
|
|
|
|
|
|
|
|
```bash
|
2019-02-15 15:39:39 +05:30
|
|
|
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\"]}}"}'
|
2016-09-29 09:46:39 +05:30
|
|
|
```
|
|
|
|
|
|
|
|
Be sure to copy paste the exact contents of `.gitlab-ci.yml` as YAML is very picky about indentation and spaces.
|
|
|
|
|
|
|
|
Example responses:
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
- Valid content:
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"status": "valid",
|
|
|
|
"errors": []
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
- Invalid content:
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"status": "invalid",
|
|
|
|
"errors": [
|
|
|
|
"variables config should be a hash of key value pairs"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
- Without the content attribute:
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"error": "content is missing"
|
|
|
|
}
|
|
|
|
```
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
[ce-5953]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5953
|