blob: ff35e948e0c26df8e4aea1b3ca09d5c8a6d78de1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
module API
class Lint < Grape::API
resource :lint do
params do
requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
end
desc 'Validation of .gitlab-ci.yml content'
post do
response = {
status: '',
error: [],
jobs: []
}
if Ci::GitlabCiYamlProcessor.errors(params[:content]).nil?
config_processor = Ci::GitlabCiYamlProcessor.new(params[:content])
config_processor.builds.each do |build|
response[:jobs].push("#{build[:name]}")
response[:status] = 'valid'
end
else
response[:error].push(Ci::GitlabCiYamlProcessor.errors(params[:content]))
response[:status] = 'invalid'
end
status 200
response
end
end
end
end
|