Send registry_url with build data to GitLab Runner

This commit is contained in:
Tomasz Maczukin 2016-11-15 03:57:43 +01:00
parent 0934f8d5fc
commit 596bbf670c
No known key found for this signature in database
GPG Key ID: 7E9EB2E4B0F625CD
2 changed files with 33 additions and 0 deletions

View File

@ -50,6 +50,10 @@ module Ci
expose :variables
expose :depends_on_builds, using: Build
expose :registry_url, if: ->(_, _) { Gitlab.config.registry.enabled } do |_|
Gitlab.config.registry.host_port
end
end
class Runner < Grape::Entity

View File

@ -17,6 +17,10 @@ describe Ci::API::API do
let!(:build) { create(:ci_build, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
let(:user_agent) { 'gitlab-ci-multi-runner 1.5.2 (1-5-stable; go1.6.3; linux/amd64)' }
before do
stub_container_registry_config(enabled: false)
end
shared_examples 'no builds available' do
context 'when runner sends version in User-Agent' do
context 'for stable version' do
@ -53,6 +57,31 @@ describe Ci::API::API do
it 'updates runner info' do
expect { register_builds }.to change { runner.reload.contacted_at }
end
context 'when registry is enabled' do
before do
stub_container_registry_config(enabled: true, host_port: 'registry.example.com:5005')
end
it 'sends registry_url key' do
register_builds info: { platform: :darwin }
expect(json_response).to have_key('registry_url')
expect(json_response['registry_url']).to eq("registry.example.com:5005")
end
end
context 'when registry is disabled' do
before do
stub_container_registry_config(enabled: false, host_port: 'registry.example.com:5005')
end
it 'does not send registry_url key' do
register_builds info: { platform: :darwin }
expect(json_response).not_to have_key('registry_url')
end
end
end
context 'when builds are finished' do