Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 2ca4b6a

Browse files
committed
support multiple contextes for batch put -- undocumented
1 parent a00e1a7 commit 2ca4b6a

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

assets/lib/commands/out.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ def output
4545
end
4646

4747
atc_url = input.source.base_url || ENV['ATC_EXTERNAL_URL']
48-
context = params.context || 'status'
49-
50-
Status.new(
51-
state: params.status,
52-
atc_url: atc_url,
53-
sha: sha,
54-
repo: repo,
55-
context: context
56-
).create!
48+
contextes = params.context || ['status']
49+
contextes = [contextes] unless contextes.is_a?(Array)
50+
51+
contextes.each do |context|
52+
Status.new(
53+
state: params.status,
54+
atc_url: atc_url,
55+
sha: sha,
56+
repo: repo,
57+
context: context
58+
).create!
59+
end
5760

5861
if params.comment
5962
comment_path = File.join(destination, params.comment)

spec/commands/out_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ def stub_json(method, uri, body)
234234
put('params' => { 'status' => 'success', 'path' => 'resource', 'context' => 'my-custom-context' }, 'source' => { 'repo' => 'jtarchie/test' })
235235
end
236236
end
237+
238+
context 'with setting multiple contextes' do
239+
it 'sets the context for each' do
240+
stub_status_post.with(body: hash_including('context' => 'concourse-ci/my-custom-context1'))
241+
stub_status_post.with(body: hash_including('context' => 'concourse-ci/my-custom-context2'))
242+
243+
put('params' => { 'status' => 'success', 'path' => 'resource', 'context' => ['my-custom-context1', 'my-custom-context2'] }, 'source' => { 'repo' => 'jtarchie/test' })
244+
end
245+
end
237246
end
238247

239248
context 'and the build failed' do

0 commit comments

Comments
 (0)