Class: Danger::AzurePipelines

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

Overview

### CI Setup

Add a script step:

“‘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

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ AzurePipelines

Returns a new instance of AzurePipelines.



42
43
44
45
46
# File 'lib/danger/ci_source/azure_pipelines.rb', line 42

def initialize(env)
  self.pull_request_id = env["SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"] || env["SYSTEM_PULLREQUEST_PULLREQUESTID"]
  self.repo_url = env["BUILD_REPOSITORY_URI"]
  self.repo_slug = env["BUILD_REPOSITORY_NAME"]
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/danger/ci_source/azure_pipelines.rb', line 21

def self.validates_as_ci?(env)
  # AGENT_ID is being used by AppCenter as well, so checking here to make sure AppCenter CI doesn't get a false positive for AzurePipelines
  # Anyone working with AzurePipelines could provide a better/truly unique env key to avoid checking for AppCenter
  !Danger::Appcenter::validates_as_ci?(env) &&
  env.key?("AGENT_ID") &&
  env["BUILD_REPOSITORY_PROVIDER"] != "TfsGit"
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/danger/ci_source/azure_pipelines.rb', line 29

def self.validates_as_pr?(env)
  return env["BUILD_REASON"] == "PullRequest"
end

Instance Method Details

#supported_request_sourcesObject



33
34
35
36
37
38
39
40
# File 'lib/danger/ci_source/azure_pipelines.rb', line 33

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