Class: Danger::Codefresh
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.
Instance Attribute Summary
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(env) ⇒ Codefresh
constructor
A new instance of Codefresh.
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env) ⇒ Codefresh
Returns a new instance of Codefresh.
43 44 45 46 47 |
# File 'lib/danger/ci_source/codefresh.rb', line 43 def initialize(env) self.repo_url = env["CF_COMMIT_URL"].to_s.gsub(%r{/commit.+$}, "") self.repo_slug = self.class.slug_from(env) self.pull_request_id = env["CF_PULL_REQUEST_NUMBER"] end |
Class Method Details
.slug_from(env) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/danger/ci_source/codefresh.rb', line 36 def self.slug_from(env) 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 |
.validates_as_ci?(env) ⇒ Boolean
24 25 26 |
# File 'lib/danger/ci_source/codefresh.rb', line 24 def self.validates_as_ci?(env) env.key?("CF_BUILD_ID") && env.key?("CF_BUILD_URL") end |
.validates_as_pr?(env) ⇒ Boolean
28 29 30 |
# File 'lib/danger/ci_source/codefresh.rb', line 28 def self.validates_as_pr?(env) return !env["CF_PULL_REQUEST_NUMBER"].to_s.empty? end |
Instance Method Details
#supported_request_sources ⇒ Object
32 33 34 |
# File 'lib/danger/ci_source/codefresh.rb', line 32 def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::GitHub] end |