Class: Danger::Codefresh

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

Overview

### CI Setup

To set up Danger on Codefresh, create a freestyle step in your Codefresh yaml configuration:

```yml
Danger:
  title: Run Danger
  image: alpine/bundle
  working_directory: ${{main_clone}}
  commands:
    - bundle install --deployment
    - bundle exec danger --verbose
```

Don't forget to add the `DANGER_GITHUB_API_TOKEN` variable to your pipeline settings so that Danger can properly post comments to your pull request.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ Codefresh

Returns a new instance of Codefresh.



49
50
51
# File 'lib/danger/ci_source/codefresh.rb', line 49

def initialize(env)
  @env = env
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/danger/ci_source/codefresh.rb', line 22

def self.validates_as_ci?(env)
  env.key?("CF_BUILD_ID") && env.key?("CF_BUILD_URL")
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/danger/ci_source/codefresh.rb', line 26

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

Instance Method Details

#pull_request_idObject



45
46
47
# File 'lib/danger/ci_source/codefresh.rb', line 45

def pull_request_id
  @env["CF_PULL_REQUEST_NUMBER"]
end

#repo_slugObject



34
35
36
37
38
# File 'lib/danger/ci_source/codefresh.rb', line 34

def repo_slug
  return "" if @env["CF_REPO_OWNER"].to_s.empty?
  return "" if @env["CF_REPO_NAME"].to_s.empty?
  "#{@env['CF_REPO_OWNER']}/#{@env['CF_REPO_NAME']}".downcase!
end

#repo_urlObject



40
41
42
43
# File 'lib/danger/ci_source/codefresh.rb', line 40

def repo_url
  return "" if @env["CF_COMMIT_URL"].to_s.empty?
  @env["CF_COMMIT_URL"].gsub(/\/commit.+$/, "")
end

#supported_request_sourcesObject



30
31
32
# File 'lib/danger/ci_source/codefresh.rb', line 30

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