get_build

in lib/network.rb [17:48]


    def get_build
      broadcast 'Checking for builds...'

      opts = {
        body: default_options.to_json,
        headers: {"Content-Type" => "application/json"},
      }

      response = self.class.post(api_url + '/builds/register.json', opts)

      if response.code == 201
        puts 'received'
        {
          id: response['id'],
          project_id: response['project_id'],
          commands: response['commands'].lines,
          repo_url: response['repo_url'],
          ref: response['sha'],
          ref_name: response['ref'],
          before_sha: response['before_sha'],
          allow_git_fetch: response['allow_git_fetch'],
          timeout: response['timeout']
        }
      elsif response.code == 403
        puts 'forbidden'
      else
        puts 'nothing'
      end
    rescue
      puts 'failed'
    end