diff options
author | Robert Speicher <robert@gitlab.com> | 2016-05-20 00:54:33 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-05-20 00:54:33 +0300 |
commit | f26389a02a48a53cccb3bb7dd1d7bcd4858c118d (patch) | |
tree | e075ed3e3a0446cc5e0a323ba50f895c0778c49b /lib | |
parent | f73def90a83e7cddda0960b2c780c59835c228fb (diff) | |
parent | 52c8b9da37451943fe97f3a687d43ae39105aaa0 (diff) |
Merge branch 'feature/runner-config-untagged-jobs' into 'master'
Add config for CI Runner that prevents it from picking untagged jobs
Closes #3456
See merge request !4039
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 1 | ||||
-rw-r--r-- | lib/api/runners.rb | 2 | ||||
-rw-r--r-- | lib/ci/api/runners.rb | 18 |
3 files changed, 11 insertions, 10 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index dbd03ea74fa..8298e3ad34c 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -408,6 +408,7 @@ module API class RunnerDetails < Runner expose :tag_list + expose :run_untagged expose :version, :revision, :platform, :architecture expose :contacted_at expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? } diff --git a/lib/api/runners.rb b/lib/api/runners.rb index 8ec91485b26..4faba9dc87b 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -49,7 +49,7 @@ module API runner = get_runner(params[:id]) authenticate_update_runner!(runner) - attrs = attributes_for_keys [:description, :active, :tag_list] + attrs = attributes_for_keys [:description, :active, :tag_list, :run_untagged] if runner.update(attrs) present runner, with: Entities::RunnerDetails, current_user: current_user else diff --git a/lib/ci/api/runners.rb b/lib/ci/api/runners.rb index 192b1d18a51..0c41f22c7c5 100644 --- a/lib/ci/api/runners.rb +++ b/lib/ci/api/runners.rb @@ -28,20 +28,20 @@ module Ci post "register" do required_attributes! [:token] + attributes = { description: params[:description], + tag_list: params[:tag_list] } + + unless params[:run_untagged].nil? + attributes[:run_untagged] = params[:run_untagged] + end + 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 |