Sha256: 1d29dbb397af78550888d15d2b5a35b64cb65fee9648d83a2ad6a8d32da808fc

Contents?: true

Size: 1.75 KB

Versions: 44

Compression:

Stored size: 1.75 KB

Contents

# https://buildkite.com/docs/agent/osx
# https://buildkite.com/docs/guides/environment-variables
require "danger/request_sources/github/github"
require "danger/request_sources/gitlab"

module Danger
  # ### CI Setup
  #
  # With BuildKite you run the server yourself, so you will want to run  it as a part of your build process.
  # It is common to have build steps, so we would recommend adding this to your scrip:
  #
  #  ```shell
  #   echo "--- Running Danger"
  #   bundle exec danger
  #  ```
  #
  # ### Token Setup
  #
  # #### GitHub
  #
  # As this is self-hosted, you will need to add the `DANGER_GITHUB_API_TOKEN` to your build user's ENV. The alternative
  # is to pass in the token as a prefix to the command `DANGER_GITHUB_API_TOKEN="123" bundle exec danger`.
  #
  # #### GitLab
  #
  # As this is self-hosted, you will need to add the `DANGER_GITLAB_API_TOKEN` to your build user's ENV. The alternative
  # is to pass in the token as a prefix to the command `DANGER_GITLAB_API_TOKEN="123" bundle exec danger`.
  #
  class Buildkite < CI
    def self.validates_as_ci?(env)
      env.key? "BUILDKITE"
    end

    def self.validates_as_pr?(env)
      exists = ["BUILDKITE_PULL_REQUEST_REPO", "BUILDKITE_PULL_REQUEST"].all? { |x| env[x] }
      exists && !env["BUILDKITE_PULL_REQUEST_REPO"].empty?
    end

    def initialize(env)
      self.repo_url = env["BUILDKITE_REPO"]
      self.pull_request_id = env["BUILDKITE_PULL_REQUEST"]

      repo_matches = self.repo_url.match(%r{([/:])([^/]+/[^/]+?)(\.git$|$)})
      self.repo_slug = repo_matches[2] unless repo_matches.nil?
    end

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

Version data entries

44 entries across 44 versions & 2 rubygems

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