Class: Danger::Appcenter
Overview
### CI Setup
Add a script step to your appcenter-post-build.sh:
“‘shell
#!/usr/bin/env bash
bundle install
bundle exec danger
“‘
### Token Setup
Add the ‘DANGER_GITHUB_API_TOKEN` to your environment variables.
Instance Attribute Summary
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
- .owner_for_github(env) ⇒ Object
-
.pr_from_env(env) ⇒ Object
Hopefully it’s a temporary workaround (same as in Codeship integration) because App Center doesn’t expose PR’s ID.
- .repo_identifier_for_github(env) ⇒ Object
- .validates_as_ci?(env) ⇒ Boolean
- .validates_as_pr?(env) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(env) ⇒ Appcenter
constructor
A new instance of Appcenter.
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env) ⇒ Appcenter
Returns a new instance of Appcenter.
51 52 53 54 55 |
# File 'lib/danger/ci_source/appcenter.rb', line 51 def initialize(env) self.pull_request_id = self.class.pr_from_env(env) self.repo_url = env["BUILD_REPOSITORY_URI"] self.repo_slug = self.class.repo_identifier_for_github(env) end |
Class Method Details
.owner_for_github(env) ⇒ Object
31 32 33 |
# File 'lib/danger/ci_source/appcenter.rb', line 31 def self.owner_for_github(env) URI.parse(env["BUILD_REPOSITORY_URI"]).path.split("/")[1] end |
.pr_from_env(env) ⇒ Object
Hopefully it’s a temporary workaround (same as in Codeship integration) because App Center doesn’t expose PR’s ID. There’s a future request github.com/Microsoft/appcenter/issues/79
43 44 45 |
# File 'lib/danger/ci_source/appcenter.rb', line 43 def self.pr_from_env(env) Danger::RequestSources::GitHub.new(nil, env).get_pr_from_branch(repo_identifier_for_github(env), env["BUILD_SOURCEBRANCHNAME"], owner_for_github(env)) end |
.repo_identifier_for_github(env) ⇒ Object
35 36 37 38 39 |
# File 'lib/danger/ci_source/appcenter.rb', line 35 def self.repo_identifier_for_github(env) repo_name = env["BUILD_REPOSITORY_NAME"] owner = owner_for_github(env) "#{owner}/#{repo_name}" end |
.validates_as_ci?(env) ⇒ Boolean
23 24 25 |
# File 'lib/danger/ci_source/appcenter.rb', line 23 def self.validates_as_ci?(env) env.key? "APPCENTER_BUILD_ID" end |
.validates_as_pr?(env) ⇒ Boolean
27 28 29 |
# File 'lib/danger/ci_source/appcenter.rb', line 27 def self.validates_as_pr?(env) return env["BUILD_REASON"] == "PullRequest" end |
Instance Method Details
#supported_request_sources ⇒ Object
47 48 49 |
# File 'lib/danger/ci_source/appcenter.rb', line 47 def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::GitHub] end |