class Danger::Screwdriver

### CI Setup

Install dependencies and add a danger step to your screwdriver.yaml:

“‘yml jobs:

danger:
  requires: [~pr, ~commit]
  steps:
    - setup: bundle install --path vendor
    - danger: bundle exec danger
  secrets:
    - DANGER_GITHUB_API_TOKEN

“‘

### Token Setup

Add the ‘DANGER_GITHUB_API_TOKEN` to your pipeline env as a [build secret](docs.screwdriver.cd/user-guide/configuration/secrets)

Public Class Methods

new(env) click to toggle source
# File lib/danger/ci_source/screwdriver.rb, line 40
def initialize(env)
  self.repo_slug = env["SCM_URL"].split(":").last.gsub(".git", "").split("#", 2).first
  self.repo_url = env["SCM_URL"].split("#", 2).first
  if env["SD_PULL_REQUEST"].to_i > 0
    self.pull_request_id = env["SD_PULL_REQUEST"]
  end
end
validates_as_ci?(env) click to toggle source
# File lib/danger/ci_source/screwdriver.rb, line 27
def self.validates_as_ci?(env)
  env.key? "SCREWDRIVER"
end
validates_as_pr?(env) click to toggle source
# File lib/danger/ci_source/screwdriver.rb, line 31
def self.validates_as_pr?(env)
  exists = ["SD_PULL_REQUEST", "SCM_URL"].all? { |x| env[x] && !env[x].empty? }
  exists && env["SD_PULL_REQUEST"].to_i > 0
end

Public Instance Methods

supported_request_sources() click to toggle source
# File lib/danger/ci_source/screwdriver.rb, line 36
def supported_request_sources
  @supported_request_sources ||= [Danger::RequestSources::GitHub]
end