summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-13 13:04:18 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-13 13:04:18 +0000
commit61f951948b7949f93ad8737e6d0a97debb123270 (patch)
treeca68113c720785b6512f56f1022742af0542fb56 /lib
parent646cb1235ae2bd65028c749d755bb91b6f2ab852 (diff)
parente93b0a4ccb0b13d88ff833525fea3683f8a4de30 (diff)
downloadgitlab-ci-61f951948b7949f93ad8737e6d0a97debb123270.tar.gz
Merge branch 'save_info_from_runner' into 'master'
Storing runner info https://dev.gitlab.org/gitlab/gitlab-ci/issues/223 ![Screenshot_2015-05-12_19.42.52](https://gitlab.com/gitlab-org/gitlab-ci/uploads/32fa390a8b2abf1f1103f4fd7b3475c0/Screenshot_2015-05-12_19.42.52.png) See merge request !98
Diffstat (limited to 'lib')
-rw-r--r--lib/api/builds.rb1
-rw-r--r--lib/api/helpers.rb11
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 0f9c2a9..67b73db 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -18,6 +18,7 @@ module API
build = RegisterBuildService.new.execute(current_runner)
if build
+ update_runner_info
present build, with: Entities::Build
else
not_found!
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index d09af26..215792a 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -39,6 +39,12 @@ module API
end
end
+ def update_runner_info
+ return unless params["info"].present?
+ info = attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"])
+ current_runner.update(info)
+ end
+
# Checks the occurrences of required attributes, each attribute must be present in the params hash
# or a Bad Request error is invoked.
#
@@ -50,10 +56,11 @@ module API
end
end
- def attributes_for_keys(keys)
+ def attributes_for_keys(keys, custom_params = nil)
+ params_hash = custom_params || params
attrs = {}
keys.each do |key|
- attrs[key] = params[key] if params[key].present?
+ attrs[key] = params_hash[key] if params_hash[key].present?
end
attrs
end