Skip to content

Commit 8b29d24

Browse files
authored
Merge pull request jtarchie#173 from cycloidio/master
Add support of concourse build environment in the base_url
2 parents a18b3a9 + 710373f commit 8b29d24

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ resource_types:
4141
linking to builds. On newer versions of Concourse ( >= v0.71.0) , the resource will
4242
automatically sets the URL.
4343

44+
This supports the [build environment](http://concourse.ci/implementing-resources.html#resource-metadata)
45+
variables provided by concourse. For example, `context: $BUILD_JOB_NAME` will set the context to the job name.
46+
4447
* `private_key`: *Optional.* Private key to use when pulling/pushing.
4548
Example:
4649
```

Diff for: assets/lib/commands/out.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def output
5252
contextes.each do |context|
5353
Status.new(
5454
state: params.status,
55-
atc_url: atc_url,
55+
atc_url: whitelist(context: atc_url),
5656
sha: sha,
5757
repo: repo,
5858
context: whitelist(context: context)

Diff for: spec/commands/out_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def stub_status_post
3939

4040
stub_json(:get, "https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}", [])
4141
ENV['BUILD_ID'] = '1234'
42+
ENV['ATC_EXTERNAL_URL'] = 'default-test-atc-url.com'
4243
end
4344

4445
def stub_json(method, uri, body)
@@ -236,6 +237,16 @@ def stub_json(method, uri, body)
236237
end
237238
end
238239

240+
context 'with base_url defined on source containing environment variable' do
241+
it 'sets the target_url for status' do
242+
ENV['BUILD_TEAM_NAME'] = 'build-env-var'
243+
stub_status_post.with(body: hash_including('target_url' => 'http://example.com/build-env-var/builds/1234'))
244+
245+
put('params' => { 'status' => 'success', 'path' => 'resource' }, 'source' => { 'repo' => 'jtarchie/test', 'base_url' => 'http://example.com/$BUILD_TEAM_NAME' })
246+
ENV['BUILD_TEAM_NAME'] = nil
247+
end
248+
end
249+
239250
context 'with no base_url defined, but with ATC_EXTERNAL_URL defined' do
240251
it 'sets the target_url for status' do
241252
ENV['ATC_EXTERNAL_URL'] = 'http://atc-endpoint.com'

0 commit comments

Comments
 (0)