summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-05-12 17:41:12 +0300
committerValery Sizov <vsv2711@gmail.com>2015-05-12 19:47:41 +0300
commite93b0a4ccb0b13d88ff833525fea3683f8a4de30 (patch)
tree5865bb56132c5e1cb55aa43044aecf122a5fc441 /lib
parent5b3450f9b4241feee5fa69f78366392015ab25f1 (diff)
downloadgitlab-ci-save_info_from_runner.tar.gz
storing runner infosave_info_from_runner
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