Sha256: f7027fa8ea24a3b2f6300cb957bd1efe058a43800b071c60e7e65914db7bf1a7

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# http://docs.gitlab.com/ce/ci/variables/README.html
require "uri"

module Danger
  # ### CI Setup
  # GitLab CI is currently not supported because GitLab's runners don't expose
  # the required values in the environment. Namely CI_MERGE_REQUEST_ID does not
  # exist as of yet, however there is an
  # [MR](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5698) fixing this.
  # If that has been merged and you are using either gitlab.com or a release
  # with that change this CISource will work.
  #
  class GitLabCI < CI
    def self.validates_as_ci?(env)
      env.key? "GITLAB_CI"
    end

    def self.validates_as_pr?(env)
      exists = ["CI_MERGE_REQUEST_ID", "CI_PROJECT_ID", "GITLAB_CI"].all? { |x| env[x] }
      exists && env["CI_MERGE_REQUEST_ID"].to_i > 0
    end

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

    def initialize(env)
      self.repo_slug = env["CI_PROJECT_ID"]
      self.pull_request_id = env["CI_MERGE_REQUEST_ID"]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
danger-3.3.0 lib/danger/ci_source/gitlab_ci.rb
danger-3.2.2 lib/danger/ci_source/gitlab_ci.rb
danger-3.2.1 lib/danger/ci_source/gitlab_ci.rb
danger-3.2.0 lib/danger/ci_source/gitlab_ci.rb
danger-3.1.1 lib/danger/ci_source/gitlab_ci.rb
danger-3.1.0 lib/danger/ci_source/gitlab_ci.rb