Class: Danger::Codemagic

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

Overview

### CI Setup

Add a script step to your workflow:

“‘

  • name: Running Danger script: |

    bundle install
    bundle exec danger
    

“‘

### Token Setup

Add the following environment variables to your workflow’s environment configuration. docs.codemagic.io/getting-started/yaml/

#### GitHub Add the ‘DANGER_GITHUB_API_TOKEN` to your build user’s ENV.

#### GitLab Add the ‘DANGER_GITLAB_API_TOKEN` to your build user’s ENV.

#### Bitbucket Cloud Add the ‘DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD` to your build user’s ENV.

#### Bitbucket server Add the ‘DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD` and `DANGER_BITBUCKETSERVER_HOST` to your build user’s ENV.

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) ⇒ Codemagic

Returns a new instance of Codemagic.



52
53
54
55
56
# File 'lib/danger/ci_source/codemagic.rb', line 52

def initialize(env)
  self.pull_request_id = env["FCI_PULL_REQUEST_NUMBER"]
  self.repo_slug = env["FCI_REPO_SLUG"]
  self.repo_url = GitRepo.new.origins # Codemagic doesn't provide a repo url env variable for n
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/danger/ci_source/codemagic.rb', line 35

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

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/danger/ci_source/codemagic.rb', line 39

def self.validates_as_pr?(env)
  return !env["FCI_PULL_REQUEST_NUMBER"].to_s.empty?
end

Instance Method Details

#supported_request_sourcesObject



43
44
45
46
47
48
49
50
# File 'lib/danger/ci_source/codemagic.rb', line 43

def supported_request_sources
  @supported_request_sources ||= [
    Danger::RequestSources::GitHub,
    Danger::RequestSources::GitLab,
    Danger::RequestSources::BitbucketServer,
    Danger::RequestSources::BitbucketCloud
  ]
end