Class: Danger::Buildkite
Overview
### 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 script:
```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`.
Instance Attribute Summary
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(env) ⇒ Buildkite
constructor
A new instance of Buildkite.
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env) ⇒ Buildkite
Returns a new instance of Buildkite.
39 40 41 42 43 44 45 |
# File 'lib/danger/ci_source/buildkite.rb', line 39 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 |
Class Method Details
.validates_as_ci?(env) ⇒ Boolean
30 31 32 |
# File 'lib/danger/ci_source/buildkite.rb', line 30 def self.validates_as_ci?(env) env.key? "BUILDKITE" end |
.validates_as_pr?(env) ⇒ Boolean
34 35 36 37 |
# File 'lib/danger/ci_source/buildkite.rb', line 34 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 |
Instance Method Details
#supported_request_sources ⇒ Object
47 48 49 |
# File 'lib/danger/ci_source/buildkite.rb', line 47 def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::GitHub, Danger::RequestSources::GitLab, Danger::RequestSources::BitbucketServer] end |