Class: GitLab::CI::Lint::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/gitlab/ci/lint/client.rb

Direct Known Subclasses

Actions

Instance Method Summary collapse

Instance Method Details

#post(url, content, headers = { "Content-Type" => "application/json"}, timeout = 10) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/ci/lint/client.rb', line 11

def post url, content, headers={ "Content-Type" => "application/json"}, timeout=10
  begin
    if content = GitLab::CI::Lint::YMLReader.new(content).get_json_content()
      body = { content: content }.to_json
      request = self.class.post(url, :body => body, :headers => headers)
      if request.code == 200
        puts "\nSuccessful request!"
        return JSON.parse(request.body)
      else
        puts "Error - Bad Request #{request.code}"
        exit
      end
    else
      puts "\nError - No Content..."
      exit
    end
  rescue => error
    puts "\nError Post - #{error}"
  end
end