Class: Danger::DotCi
Overview
### CI Setup DotCi is a layer on top of jenkins. So, if you’re using DotCi, you’re hosting your own environment.
### Token Setup
#### GitHub As you own the machine, it’s up to you to add the environment variable for the ‘DANGER_GITHUB_API_TOKEN`.
Instance Attribute Summary
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
- .pull_request_id(env) ⇒ Object
- .repo_url(env) ⇒ Object
- .validates_as_ci?(env) ⇒ Boolean
- .validates_as_pr?(env) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(env) ⇒ DotCi
constructor
A new instance of DotCi.
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env) ⇒ DotCi
Returns a new instance of DotCi.
29 30 31 32 33 34 |
# File 'lib/danger/ci_source/dotci.rb', line 29 def initialize(env) self.repo_url = self.class.repo_url(env) self.pull_request_id = self.class.pull_request_id(env) repo_matches = self.repo_url.match(%r{([/:])([^/]+/[^/]+)$}) self.repo_slug = repo_matches[2].gsub(/\.git$/, "") unless repo_matches.nil? end |
Class Method Details
.pull_request_id(env) ⇒ Object
36 37 38 |
# File 'lib/danger/ci_source/dotci.rb', line 36 def self.pull_request_id(env) env["DOTCI_PULL_REQUEST"] end |
.repo_url(env) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/danger/ci_source/dotci.rb', line 40 def self.repo_url(env) if env["DOTCI_INSTALL_PACKAGES_GIT_CLONE_URL"] env["DOTCI_INSTALL_PACKAGES_GIT_CLONE_URL"] elsif env["DOTCI_DOCKER_COMPOSE_GIT_CLONE_URL"] env["DOTCI_DOCKER_COMPOSE_GIT_CLONE_URL"] else env["GIT_URL"] end end |
.validates_as_ci?(env) ⇒ Boolean
15 16 17 |
# File 'lib/danger/ci_source/dotci.rb', line 15 def self.validates_as_ci?(env) env.key? "DOTCI" end |
.validates_as_pr?(env) ⇒ Boolean
19 20 21 |
# File 'lib/danger/ci_source/dotci.rb', line 19 def self.validates_as_pr?(env) !env["DOTCI_PULL_REQUEST"].nil? && !env["DOTCI_PULL_REQUEST"].match(/^[0-9]+$/).nil? end |
Instance Method Details
#supported_request_sources ⇒ Object
23 24 25 26 27 |
# File 'lib/danger/ci_source/dotci.rb', line 23 def supported_request_sources @supported_request_sources ||= [ Danger::RequestSources::GitHub ] end |