blob: 2757b800af0b63fd2d56c0c87878bc425d3b18df (
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
34
35
36
|
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: '',
errors: [],
jobs: []
}
if !Ci::GitlabCiYamlProcessor.errors(@content).nil?
status 200
response[:errors].push(Ci::GitlabCiYamlProcessor.errors(@content))
response[:status] = 'invalid'
response
end
config_processor = Ci::GitlabCiYamlProcessor.new(params[:content])
config_processor.builds.each do |build|
response[:jobs].push("#{build[:name]}")
response[:status] = 'valid'
end
status 200
response
end
end
end
end
|