Skip to content

Commit

Permalink
Allow runner to pass tag_list during registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Jan 27, 2015
1 parent 4d4bdff commit e8d7d32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v7.8.0
- Fix OAuth login with GitLab installed in relative URL
- GitLab CI has same version as GitLab since now
- Allow to pass hostname and tag list during Runner's registration

v5.4.1
- Fix 500 if on builds page if build has no job
Expand Down
10 changes: 8 additions & 2 deletions lib/api/runners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ class Runners < Grape::API
runner =
if params[:token] == GitlabCi::REGISTRATION_TOKEN
# Create shared runner. Requires admin access
Runner.create(description: params[:hostname])
Runner.create(
description: params[:hostname],
tag_list: params[:tag_list]
)
elsif project = Project.find_by(token: params[:token])
# Create a specific runner for project.
project.runners.create(description: params[:hostname])
project.runners.create(
description: params[:hostname],
tag_list: params[:tag_list]
)
end

return forbidden! unless runner
Expand Down
7 changes: 7 additions & 0 deletions spec/requests/api/runners_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
it { Runner.first.description.should == "server.hostname" }
end

describe "should create a runner with tags" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, tag_list: "tag1, tag2" }

it { response.status.should == 201 }
it { Runner.first.tag_list.sort.should == ["tag1", "tag2"] }
end

describe "should create a runner if project token provided" do
let(:project) { FactoryGirl.create(:project) }
before { post api("/runners/register"), token: project.token }
Expand Down

0 comments on commit e8d7d32

Please sign in to comment.