Class: Danger::AppVeyor

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

Overview

CI Setup

Install dependencies and add a danger step to your appveyor.yml.

install:
- cmd: >-
    set PATH=C:\Ruby25-x64\bin;%PATH%

    bundle install
after_test:
- cmd: >-
    bundle exec danger

Token Setup

For public repositories, add your plain token to environment variables in appveyor.yml. Encrypted environment variables will not be decrypted on PR builds. see here: https://www.appveyor.com/docs/build-configuration/#secure-variables

environment:
  DANGER_GITHUB_API_TOKEN: <YOUR_TOKEN_HERE>

For private repositories, enter your token in Settings>Environment>Environment variables>Add variable and turn on variable encryption. You will see encrypted variable text in Settings>Export YAML so just copy to your appveyor.yml.

environment:
  DANGER_GITHUB_API_TOKEN:
    secure: <YOUR_ENCRYPTED_TOKEN_HERE>

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) ⇒ AppVeyor

Returns a new instance of AppVeyor.



51
52
53
54
55
# File 'lib/danger/ci_source/appveyor.rb', line 51

def initialize(env)
  self.repo_slug = env["APPVEYOR_REPO_NAME"]
  self.pull_request_id = env["APPVEYOR_PULL_REQUEST_NUMBER"]
  self.repo_url = GitRepo.new.origins # AppVeyor doesn't provide a repo url env variable for now
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/danger/ci_source/appveyor.rb', line 41

def self.validates_as_ci?(env)
  env.key? "APPVEYOR"
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
# File 'lib/danger/ci_source/appveyor.rb', line 45

def self.validates_as_pr?(env)
  return false unless env.key? "APPVEYOR_PULL_REQUEST_NUMBER"

  env["APPVEYOR_PULL_REQUEST_NUMBER"].to_i > 0
end

Instance Method Details

#supported_request_sourcesObject



57
58
59
60
61
62
63
64
# File 'lib/danger/ci_source/appveyor.rb', line 57

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