Sha256: 15ee66cdbc71e5bf83bddfe5110377e2b45b089203b1b100f6c16e2d1125a0a8

Contents?: true

Size: 1.36 KB

Versions: 46

Compression:

Stored size: 1.36 KB

Contents

require "danger/request_sources/github/github"

module Danger
  # https://groupon.github.io/DotCi

  # ### 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`.
  #
  class DotCi < CI
    def self.validates_as_ci?(env)
      env.key? "DOTCI"
    end

    def self.validates_as_pr?(env)
      !env["DOTCI_PULL_REQUEST"].nil? && !env["DOTCI_PULL_REQUEST"].match(/^[0-9]+$/).nil?
    end

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

    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

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

    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
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
danger-9.5.1 lib/danger/ci_source/dotci.rb
danger-9.5.0 lib/danger/ci_source/dotci.rb
danger-9.4.3 lib/danger/ci_source/dotci.rb
danger-9.4.2 lib/danger/ci_source/dotci.rb
danger-9.4.1 lib/danger/ci_source/dotci.rb
danger-9.4.0 lib/danger/ci_source/dotci.rb
danger-9.3.2 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.36 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.35 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.34 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.33 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.32 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.31 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.30 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.29 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.28 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.27 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.26 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.25 lib/danger/ci_source/dotci.rb
danger-additional-logging-0.0.24 lib/danger/ci_source/dotci.rb