Set run untagged option when registering a runner
This commit is contained in:
parent
9ba72378fc
commit
b8cf2a340b
2 changed files with 38 additions and 12 deletions
|
@ -28,20 +28,17 @@ module Ci
|
|||
post "register" do
|
||||
required_attributes! [:token]
|
||||
|
||||
attributes = { description: params[:description],
|
||||
tag_list: params[:tag_list],
|
||||
run_untagged: params[:run_untagged] || true }
|
||||
|
||||
runner =
|
||||
if runner_registration_token_valid?
|
||||
# Create shared runner. Requires admin access
|
||||
Ci::Runner.create(
|
||||
description: params[:description],
|
||||
tag_list: params[:tag_list],
|
||||
is_shared: true
|
||||
)
|
||||
Ci::Runner.create(attributes.merge(is_shared: true))
|
||||
elsif project = Project.find_by(runners_token: params[:token])
|
||||
# Create a specific runner for project.
|
||||
project.runners.create(
|
||||
description: params[:description],
|
||||
tag_list: params[:tag_list]
|
||||
)
|
||||
project.runners.create(attributes)
|
||||
end
|
||||
|
||||
return forbidden! unless runner
|
||||
|
|
|
@ -15,13 +15,17 @@ describe Ci::API::API do
|
|||
context 'when runner token is provided' do
|
||||
before { post ci_api("/runners/register"), token: registration_token }
|
||||
|
||||
it 'creates runner' do
|
||||
it 'creates runner with default values' do
|
||||
expect(response.status).to eq(201)
|
||||
expect(Ci::Runner.first.run_untagged).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when runner description is provided' do
|
||||
before { post ci_api("/runners/register"), token: registration_token, description: "server.hostname" }
|
||||
before do
|
||||
post ci_api("/runners/register"), token: registration_token,
|
||||
description: "server.hostname"
|
||||
end
|
||||
|
||||
it 'creates runner' do
|
||||
expect(response.status).to eq(201)
|
||||
|
@ -30,7 +34,10 @@ describe Ci::API::API do
|
|||
end
|
||||
|
||||
context 'when runner tags are provided' do
|
||||
before { post ci_api("/runners/register"), token: registration_token, tag_list: "tag1, tag2" }
|
||||
before do
|
||||
post ci_api("/runners/register"), token: registration_token,
|
||||
tag_list: "tag1, tag2"
|
||||
end
|
||||
|
||||
it 'creates runner' do
|
||||
expect(response.status).to eq(201)
|
||||
|
@ -38,6 +45,28 @@ describe Ci::API::API do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when option for running untagged jobs is provided' do
|
||||
context 'when tags are provided' do
|
||||
it 'creates runner' do
|
||||
post ci_api("/runners/register"), token: registration_token,
|
||||
run_untagged: false,
|
||||
tag_list: ['tag']
|
||||
|
||||
expect(response.status).to eq(201)
|
||||
expect(Ci::Runner.first.run_untagged).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when tags are not provided' do
|
||||
it 'does not create runner' do
|
||||
post ci_api("/runners/register"), token: registration_token,
|
||||
run_untagged: false
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when project token is provided' do
|
||||
let(:project) { FactoryGirl.create(:empty_project) }
|
||||
before { post ci_api("/runners/register"), token: project.runners_token }
|
||||
|
|
Loading…
Reference in a new issue