summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-04 00:07:52 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-04 00:07:52 +0000
commit4fe93274dec62ff7361a67be88e320131d66b788 (patch)
tree98ae79e3101ffd6569fc48bb4c7ad8808540ceb8 /app/models/ci/build.rb
parentbbaf2bb0438b1c71020d9d216feb528add225a7f (diff)
downloadgitlab-ce-4fe93274dec62ff7361a67be88e320131d66b788.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index f79a5682963..fd099107fe7 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -59,15 +59,11 @@ module Ci
##
# Since Gitlab 11.5, deployments records started being created right after
# `ci_builds` creation. We can look up a relevant `environment` through
- # `deployment` relation today. This is much more efficient than expanding
- # environment name with variables.
+ # `deployment` relation today.
# (See more https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/22380)
#
- # However, we have to still expand environment name if it's a stop action,
- # because `deployment` persists information for start action only.
- #
- # We will follow up this by persisting expanded name in build metadata or
- # persisting stop action in database.
+ # Since Gitlab 12.9, we started persisting the expanded environment name to
+ # avoid repeated variables expansion in `action: stop` builds as well.
def persisted_environment
return unless has_environment?
@@ -465,7 +461,14 @@ module Ci
return unless has_environment?
strong_memoize(:expanded_environment_name) do
- ExpandVariables.expand(environment, -> { simple_variables })
+ # We're using a persisted expanded environment name in order to avoid
+ # variable expansion per request.
+ if Feature.enabled?(:ci_persisted_expanded_environment_name, project, default_enabled: true) &&
+ metadata&.expanded_environment_name.present?
+ metadata.expanded_environment_name
+ else
+ ExpandVariables.expand(environment, -> { simple_variables })
+ end
end
end