Class: Danger::BitbucketPipelines

Inherits:
CI
  • Object
show all
Defined in:
lib/danger/ci_source/bitbucket_pipelines.rb

Overview

### CI Setup

Install dependencies and add a danger step to your ‘bitbucket-pipelines.yml`.

“‘yaml

script:
  - bundle exec danger --verbose

“‘

### Token Setup

Add ‘DANGER_BITBUCKETCLOUD_USERNAME` and `DANGER_BITBUCKETCLOUD_PASSWORD` to your pipeline repository variable or instead using `DANGER_BITBUCKETCLOUD_OAUTH_KEY` and `DANGER_BITBUCKETCLOUD_OAUTH_SECRET`.

You can find them in Settings > Pipelines > Repository Variables

Instance Attribute Summary

Attributes inherited from CI

#pull_request_id, #repo_slug, #repo_url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ BitbucketPipelines

Returns a new instance of BitbucketPipelines.



32
33
34
35
36
# File 'lib/danger/ci_source/bitbucket_pipelines.rb', line 32

def initialize(env)
  self.repo_url = env["BITBUCKET_GIT_HTTP_ORIGIN"]
  self.repo_slug = "#{env["BITBUCKET_REPO_OWNER"]}/#{env["BITBUCKET_REPO_SLUG"]}"
  self.pull_request_id = env["BITBUCKET_PR_ID"]
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/danger/ci_source/bitbucket_pipelines.rb', line 20

def self.validates_as_ci?(env)
  env.key? "BITBUCKET_BUILD_NUMBER"
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/danger/ci_source/bitbucket_pipelines.rb', line 24

def self.validates_as_pr?(env)
  env.key? "BITBUCKET_PR_ID"
end

Instance Method Details

#supported_request_sourcesObject



28
29
30
# File 'lib/danger/ci_source/bitbucket_pipelines.rb', line 28

def supported_request_sources
  @supported_request_sources ||= [Danger::RequestSources::BitbucketCloud]
end