Class: Danger::Drone
Overview
### CI Setup
With Drone you run the docker images yourself, so you will want to add ‘bundle exec danger` at the end of your `.drone.yml`.
```shell
build:
image: golang
commands:
- ...
- bundle exec danger
```
### Token Setup
As this is self-hosted, you will need to expose the ‘DANGER_GITHUB_API_TOKEN` as a secret to your builds:
Drone secrets: readme.drone.io/usage/secret-guide/ NOTE: This is a new syntax in DroneCI 0.6+
“‘yml
build:
image: golang
secrets:
- DANGER_GITHUB_API_TOKEN
commands:
- ...
- bundle exec danger
“‘
Instance Attribute Summary
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
- .validates_as_ci?(env) ⇒ Boolean
-
.validates_as_ci_post_06?(env) ⇒ Boolean
Check if this build is valid for CI with drone 0.6 or later.
-
.validates_as_ci_pre_06?(env) ⇒ Boolean
Checks if this build is valid for CI with drone 0.5 or earlier.
- .validates_as_pr?(env) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(env) ⇒ Drone
constructor
A new instance of Drone.
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env) ⇒ Drone
Returns a new instance of Drone.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/danger/ci_source/drone.rb', line 49 def initialize(env) if self.class.validates_as_ci_post_06?(env) self.repo_slug = "#{env['DRONE_REPO_OWNER']}/#{env['DRONE_REPO_NAME']}" self.repo_url = env["DRONE_REPO_LINK"] if self.class.validates_as_ci_post_06?(env) elsif self.class.validates_as_ci_pre_06?(env) self.repo_slug = env["DRONE_REPO"] self.repo_url = GitRepo.new.origins end self.pull_request_id = env["DRONE_PULL_REQUEST"] end |
Class Method Details
.validates_as_ci?(env) ⇒ Boolean
37 38 39 |
# File 'lib/danger/ci_source/drone.rb', line 37 def self.validates_as_ci?(env) validates_as_ci_post_06?(env) or validates_as_ci_pre_06?(env) end |
.validates_as_ci_post_06?(env) ⇒ Boolean
Check if this build is valid for CI with drone 0.6 or later
62 63 64 |
# File 'lib/danger/ci_source/drone.rb', line 62 def self.validates_as_ci_post_06?(env) env.key? "DRONE_REPO_OWNER" and env.key? "DRONE_REPO_NAME" end |
.validates_as_ci_pre_06?(env) ⇒ Boolean
Checks if this build is valid for CI with drone 0.5 or earlier
67 68 69 |
# File 'lib/danger/ci_source/drone.rb', line 67 def self.validates_as_ci_pre_06?(env) env.key? "DRONE_REPO" end |
.validates_as_pr?(env) ⇒ Boolean
41 42 43 |
# File 'lib/danger/ci_source/drone.rb', line 41 def self.validates_as_pr?(env) env["DRONE_PULL_REQUEST"].to_i > 0 end |
Instance Method Details
#supported_request_sources ⇒ Object
45 46 47 |
# File 'lib/danger/ci_source/drone.rb', line 45 def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::GitHub, Danger::RequestSources::GitLab] end |