Sha256: 9fa4124d5d36f4b55a2b37261c0b2d760cea31170e2f0c88a9a01d36ae8b0443

Contents?: true

Size: 1.76 KB

Versions: 138

Compression:

Stored size: 1.76 KB

Contents

# Following the advice from @czechboy0 https://github.com/danger/danger/issues/171
# https://github.com/czechboy0/Buildasaur
require "danger/request_sources/github/github"

module Danger
  # ### CI Setup
  #
  # If you're bold enough to use Xcode Bots. You will need to use [Buildasaur](https://github.com/czechboy0/Buildasaur)
  # in order to work with Danger. This will set up your build environment for you, as the name of the bot contains all
  # of the environment variables that Danger needs to work.
  #
  # With Buildasaur set up, you can edit your job to add `bundle exec danger` as a post-action build script.
  #
  # ### Token Setup
  #
  # As this is self-hosted, you will need to add the `DANGER_GITHUB_API_TOKEN` to your build user's ENV. The alternative
  # is to pass in the token as a prefix to the command `DANGER_GITHUB_API_TOKEN="123" bundle exec danger`.`.
  #
  class XcodeServer < CI
    def self.validates_as_ci?(env)
      env.key? "XCS_BOT_NAME"
    end

    def self.validates_as_pr?(env)
      value = env["XCS_BOT_NAME"]
      !value.nil? && value.include?("BuildaBot")
    end

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

    def initialize(env)
      bot_name = env["XCS_BOT_NAME"]
      return if bot_name.nil?

      repo_matches = bot_name.match(/\[(.+)\]/)
      self.repo_slug = repo_matches[1] unless repo_matches.nil?
      pull_request_id_matches = bot_name.match(/#(\d+)/)
      self.pull_request_id = pull_request_id_matches[1] unless pull_request_id_matches.nil?
      self.repo_url = GitRepo.new.origins # Xcode Server doesn't provide a repo url env variable :/
    end
  end
end

Version data entries

138 entries across 138 versions & 2 rubygems

Version Path
danger-6.0.8 lib/danger/ci_source/xcode_server.rb
danger-6.0.7 lib/danger/ci_source/xcode_server.rb
danger-6.0.6 lib/danger/ci_source/xcode_server.rb
danger-6.0.5 lib/danger/ci_source/xcode_server.rb
danger-6.0.4 lib/danger/ci_source/xcode_server.rb
danger-6.0.3 lib/danger/ci_source/xcode_server.rb
danger-6.0.2 lib/danger/ci_source/xcode_server.rb
danger-6.0.1 lib/danger/ci_source/xcode_server.rb
danger-6.0.0 lib/danger/ci_source/xcode_server.rb
danger-5.16.1 lib/danger/ci_source/xcode_server.rb
danger-5.16.0 lib/danger/ci_source/xcode_server.rb
danger-5.15.0 lib/danger/ci_source/xcode_server.rb
danger-5.14.0 lib/danger/ci_source/xcode_server.rb
danger-5.13.0 lib/danger/ci_source/xcode_server.rb
danger-5.12.0 lib/danger/ci_source/xcode_server.rb
danger-5.11.1 lib/danger/ci_source/xcode_server.rb
danger-5.11.0 lib/danger/ci_source/xcode_server.rb
danger-5.10.3 lib/danger/ci_source/xcode_server.rb
danger-5.10.2 lib/danger/ci_source/xcode_server.rb
danger-5.10.1 lib/danger/ci_source/xcode_server.rb