Commit 596bbf67 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Send registry_url with build data to GitLab Runner

parent 0934f8d5
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment