Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 18:06:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 18:06:17 +0300
commitb5ad06174bb1de39438c90847abb86ac6988e944 (patch)
tree1bb386b92f023fd2a8f776ccc10386675b3b1ef9 /app/services/git
parent0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/git')
-rw-r--r--app/services/git/base_hooks_service.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/services/git/base_hooks_service.rb b/app/services/git/base_hooks_service.rb
index 0801fd4d03f..d935d9e8cdc 100644
--- a/app/services/git/base_hooks_service.rb
+++ b/app/services/git/base_hooks_service.rb
@@ -85,12 +85,36 @@ module Git
before: oldrev,
after: newrev,
ref: ref,
+ variables_attributes: generate_vars_from_push_options || [],
push_options: params[:push_options] || {},
checkout_sha: Gitlab::DataBuilder::Push.checkout_sha(
project.repository, newrev, ref)
}
end
+ def ci_variables_from_push_options
+ strong_memoize(:ci_variables_from_push_options) do
+ params[:push_options]&.deep_symbolize_keys&.dig(:ci, :variable)
+ end
+ end
+
+ def generate_vars_from_push_options
+ return [] unless ci_variables_from_push_options
+
+ ci_variables_from_push_options.map do |var_definition, _count|
+ key, value = var_definition.to_s.split("=", 2)
+
+ # Accept only valid format. We ignore the following formats
+ # 1. "=123". In this case, `key` will be an empty string
+ # 2. "FOO". In this case, `value` will be nil.
+ # However, the format "FOO=" will result in key beign `FOO` and value
+ # being an empty string. This is acceptable.
+ next if key.blank? || value.nil?
+
+ { "key" => key, "variable_type" => "env_var", "secret_value" => value }
+ end.compact
+ end
+
def push_data_params(commits:, with_changed_files: true)
{
oldrev: oldrev,