Add Documentation to Ci Lint API
This commit is contained in:
parent
0d81fd05b9
commit
b63d20a106
|
@ -41,8 +41,10 @@ following locations:
|
||||||
- [Sidekiq metrics](sidekiq_metrics.md)
|
- [Sidekiq metrics](sidekiq_metrics.md)
|
||||||
- [System Hooks](system_hooks.md)
|
- [System Hooks](system_hooks.md)
|
||||||
- [Tags](tags.md)
|
- [Tags](tags.md)
|
||||||
- [Users](users.md)
|
|
||||||
- [Todos](todos.md)
|
- [Todos](todos.md)
|
||||||
|
- [Users](users.md)
|
||||||
|
- [Validate the .gitlab-ci.yaml](ci_lint.md)
|
||||||
|
|
||||||
|
|
||||||
### Internal CI API
|
### Internal CI API
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Validate the .gitlab-ci.yaml
|
||||||
|
|
||||||
|
Check whether your .gitlab-ci.yml file is valid.
|
||||||
|
|
||||||
|
```
|
||||||
|
POST ci/lint
|
||||||
|
```
|
||||||
|
|
||||||
|
| Attribute | Type | Required | Description |
|
||||||
|
| ---------- | ------- | -------- | -------- |
|
||||||
|
| `content` | hash | yes | the .gitlab-ci.yaml content|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --request POST "https://gitlab.example.com/api/v3/ci/lint?content=YAML+Content"
|
||||||
|
```
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
* valid content
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": "valid",
|
||||||
|
"errors": []
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* invalid content
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": "invalid",
|
||||||
|
"errors": [
|
||||||
|
"variables config should be a hash of key value pairs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* without the content attribute
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "content is missing"
|
||||||
|
}
|
||||||
|
```
|
|
@ -7,14 +7,14 @@ module API
|
||||||
|
|
||||||
namespace :ci do
|
namespace :ci do
|
||||||
post '/lint' do
|
post '/lint' do
|
||||||
errors = Ci::GitlabCiYamlProcessor.validation_message(params[:content])
|
error = Ci::GitlabCiYamlProcessor.validation_message(params[:content])
|
||||||
|
|
||||||
status 200
|
status 200
|
||||||
|
|
||||||
if errors.blank?
|
if error.blank?
|
||||||
{ status: 'valid', errors: [] }
|
{ status: 'valid', errors: [] }
|
||||||
else
|
else
|
||||||
{ status: 'invalid', errors: [errors] }
|
{ status: 'invalid', errors: [error] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue