Class: Danger::DotCi

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

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

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ DotCi

Returns a new instance of DotCi.



31
32
33
34
35
36
# File 'lib/danger/ci_source/dotci.rb', line 31

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



38
39
40
# File 'lib/danger/ci_source/dotci.rb', line 38

def self.pull_request_id(env)
  env["DOTCI_PULL_REQUEST"]
end

.repo_url(env) ⇒ Object



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

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/danger/ci_source/dotci.rb', line 17

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

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/danger/ci_source/dotci.rb', line 21

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_sourcesObject



25
26
27
28
29
# File 'lib/danger/ci_source/dotci.rb', line 25

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