Sha256: f0e7a7c09be6af00207631d2a899cf36884e06e1925db86caf5af1d155ec0879

Contents?: true

Size: 1.38 KB

Versions: 46

Compression:

Stored size: 1.38 KB

Contents

# https://semaphoreci.com/docs/available-environment-variables.html
require "danger/request_sources/github/github"

module Danger
  #  ### CI Setup
  #
  #  To set up Danger on Codefresh, create a freestyle step in your Codefresh yaml configuration:
  #
  #  ```yml
  #  Danger:
  #    title: Run Danger
  #    image: alpine/bundle
  #    working_directory: ${{main_clone}}
  #    commands:
  #      - bundle install --deployment
  #      - bundle exec danger --verbose
  #  ```
  #
  #  Don't forget to add the `DANGER_GITHUB_API_TOKEN` variable to your pipeline settings so that Danger can properly post comments to your pull request.
  #
  class Codefresh < CI
    def self.validates_as_ci?(env)
      env.key?("CF_BUILD_ID") && env.key?("CF_BUILD_URL")
    end

    def self.validates_as_pr?(env)
      return !env["CF_PULL_REQUEST_NUMBER"].to_s.empty?
    end

    def supported_request_sources
      @supported_request_sources ||= [Danger::RequestSources::GitHub]
    end

    def self.slug_from(env)
      return "" if env["CF_REPO_OWNER"].to_s.empty?
      return "" if env["CF_REPO_NAME"].to_s.empty?

      "#{env['CF_REPO_OWNER']}/#{env['CF_REPO_NAME']}".downcase!
    end

    def initialize(env)
      self.repo_url = env["CF_COMMIT_URL"].to_s.gsub(%r{/commit.+$}, "")
      self.repo_slug = self.class.slug_from(env)
      self.pull_request_id = env["CF_PULL_REQUEST_NUMBER"]
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
danger-9.5.1 lib/danger/ci_source/codefresh.rb
danger-9.5.0 lib/danger/ci_source/codefresh.rb
danger-9.4.3 lib/danger/ci_source/codefresh.rb
danger-9.4.2 lib/danger/ci_source/codefresh.rb
danger-9.4.1 lib/danger/ci_source/codefresh.rb
danger-9.4.0 lib/danger/ci_source/codefresh.rb
danger-9.3.2 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.36 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.35 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.34 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.33 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.32 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.31 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.30 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.29 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.28 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.27 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.26 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.25 lib/danger/ci_source/codefresh.rb
danger-additional-logging-0.0.24 lib/danger/ci_source/codefresh.rb