Class: BitBucket::Repos::Statuses

Inherits:
API
  • Object
show all
Defined in:
lib/bitbucket_rest_api/repos/statuses.rb

Constant Summary

Constants included from Validations

Validations::VALID_API_KEYS

Constants included from Validations::Token

Validations::Token::TOKEN_REQUIRED, Validations::Token::TOKEN_REQUIRED_REGEXP

Constants included from BitBucket::Request

BitBucket::Request::METHODS, BitBucket::Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ALLOWED_OPTIONS

Constants included from Constants

Constants::ACCEPT, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::QUERY_STR_SEP, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT

Instance Method Summary collapse

Methods inherited from API

#_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, inherited, #initialize, #method_missing, #process_basic_auth, #setup, #update_and_validate_user_repo_params

Methods included from Helpers::RepositoryHelper

#sanitize_repository_name

Methods included from Normalizer

#normalize!

Methods included from ParameterFilter

#filter!

Methods included from AutoloadHelper

#autoload_all, #lookup_constant, #register_constant

Methods included from Validations::Required

#assert_required_keys, #assert_required_values_present, #parse_values

Methods included from Validations::Token

#validates_token_for

Methods included from Validations::Format

#assert_valid_values

Methods included from Validations::Presence

#_validate_presence_of, #_validate_user_repo_params

Methods included from BitBucket::Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request, #retry_token_refresh_errors

Methods included from Connection

#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack

Methods included from Authorization

#authenticated?, #authentication, #basic_authed?

Constructor Details

This class inherits a constructor from BitBucket::API

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BitBucket::API

Instance Method Details

#create(user_name, repo_name, sha, state, key, url, options = {}) ⇒ Object

Add build status to commit

Parameters

<tt>:user_name</tt> - Required string. The account of the repository owner.
<tt>:repo_name</tt> - Required string. The repository name.
<tt>:sha</tt> - Requrired string. The SHA1 value for the commit where you want to add the build status.
<tt>:state</tt> - Required String. An indication of the status of the commit: (INPROGRESS, SUCCESSFUL, or FAILED)
<tt>:key</tt> - Required String. A key that the vendor or build system supplies to identify the submitted build status.
<tt>:url</tt> - Required String. The URL for the vendor or system that produces the build.
<tt>:options</tt> Optional hash. Containing the following optional parameters:
   * <tt>description</tt> - A user-defined description of the build. For example, 4 out of 128 tests passed.
   * <tt>name<tt> - The name of the build. Your build system may provide the name, which will also appear in Bitbucket. For example, Unit Tests.

Examples

bitbucket = BitBucket.new
bitbucket.repos.create_status(client.repos.statuses.create('homer',
                        'monorail',
                        'e14caad7c501e0ae52daef24b26aa2625b7534e6',
                        'SUCCESSFUL',
                        'BAMBOO-PROJECT-X',
                        'https://example.com/path/to/build/info',
                        'name' => 'this is covered by build_concurrency_spec',
                        'description' => 'Changes by John Doe')


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bitbucket_rest_api/repos/statuses.rb', line 30

def create(user_name, repo_name, sha, state, key, url, options = {})
   _update_user_repo_params(user_name, repo_name)
   _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of(sha, state, key, url)

  build_options = options.merge({
    "state" => state,
    "key" => key,
    "url" => url
  })

  url = if BitBucket.options[:bitbucket_server]
          "/rest/build-status/1.0/commits/#{sha}"
        else
          "/2.0/repositories/#{user}/#{sanitize_repository_name(repo)}/commit/#{sha}/statuses/build"
        end

  faraday_options = { headers: { "Content-Type" => "application/json" } }
  post_request(url, build_options, faraday_options)
end