class GitLab::CI::Lint::Client

Public Instance Methods

post(url, content, headers={ "Content-Type" => "application/json"}) click to toggle source
# 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