summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-04-19 10:31:46 -0500
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-20 12:18:41 -0500
commit800ee75aa5f65fc41f32c8d7f3519256cd37c645 (patch)
tree7c4eb77281c943d13e9894577bc2755f4ec72e76 /app
parent0dd6d25c251beffca510094281ac8403fad6d8d0 (diff)
downloadgitlab-ce-800ee75aa5f65fc41f32c8d7f3519256cd37c645.tar.gz
Ensure deploy tokens variables are not available in the context of only/except
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/build.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index f3972e0cd26..8db07553665 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -27,6 +27,7 @@ module Ci
has_one :metadata, class_name: 'Ci::BuildMetadata'
delegate :timeout, to: :metadata, prefix: true, allow_nil: true
+ delegate :gitlab_deploy_token, to: :project
##
# The "environment" field for builds is a String, and is the unexpanded name!
@@ -604,6 +605,8 @@ module Ci
.append(key: 'CI_REGISTRY_USER', value: CI_REGISTRY_USER)
.append(key: 'CI_REGISTRY_PASSWORD', value: token, public: false)
.append(key: 'CI_REPOSITORY_URL', value: repo_url, public: false)
+
+ variables.concat(deploy_token_variables) if gitlab_deploy_token
end
end
@@ -624,7 +627,6 @@ module Ci
variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request
variables.append(key: "CI_JOB_MANUAL", value: 'true') if action?
variables.concat(legacy_variables)
- variables.concat(deploy_token_variables) if project.gitlab_deploy_token
end
end
@@ -657,8 +659,8 @@ module Ci
def deploy_token_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_DEPLOY_USER', value: DeployToken::GITLAB_DEPLOY_TOKEN_NAME)
- variables.append(key: 'CI_DEPLOY_PASSWORD', value: project.gitlab_deploy_token.token)
+ variables.append(key: 'CI_DEPLOY_USER', value: gitlab_deploy_token.name)
+ variables.append(key: 'CI_DEPLOY_PASSWORD', value: gitlab_deploy_token.token)
end
end