Class: Danger::Concourse

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

Overview

Concourse CI Integration

https://concourse-ci.org/

CI Setup

With Concourse, you run the docker images yourself, so you will want to add yarn danger ci within one of your build jobs.

```shell
build:
 image: golang
   commands:
     - ...
     - yarn danger ci
```

Environment Variable Setup

As this is self-hosted, you will need to add the CONCOURSE environment variable export CONCOURSE=true to your build environment, as well as setting environment variables for PULL_REQUEST_ID and REPO_SLUG. Assuming you are using the github pull request resource https://github.com/jtarchie/github-pullrequest-resource the id of the PR can be accessed from git config --get pullrequest.id.

Token Setup

Once again as this is self-hosted, you will need to add DANGER_GITHUB_API_TOKEN environment variable to the build environment. The suggested method of storing the token is within the vault - https://concourse-ci.org/creds.html

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

Returns a new instance of Concourse.



53
54
55
56
57
58
59
60
# File 'lib/danger/ci_source/concourse.rb', line 53

def initialize(env)
  self.repo_slug = env["REPO_SLUG"]

  if env["PULL_REQUEST_ID"].to_i > 0
    self.pull_request_id = env["PULL_REQUEST_ID"]
  end
  self.repo_url = GitRepo.new.origins
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/danger/ci_source/concourse.rb', line 35

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

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/danger/ci_source/concourse.rb', line 39

def self.validates_as_pr?(env)
  exists = ["PULL_REQUEST_ID", "REPO_SLUG"].all? { |x| env[x] && !env[x].empty? }
  exists && env["PULL_REQUEST_ID"].to_i > 0
end

Instance Method Details

#supported_request_sourcesObject



44
45
46
47
48
49
50
51
# File 'lib/danger/ci_source/concourse.rb', line 44

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