diff options
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 480b90b279e..ece68cd3753 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -251,7 +251,15 @@ class Group < Namespace def secret_variables_for(ref, project) list_of_ids = ([self] + ancestors).map { |l| l.id } - variables = Ci::GroupVariable.where("group_id IN (#{list_of_ids.join(", ")})") + + order = list_of_ids.map.with_index do |id, index| + "WHEN #{id} THEN #{index}" + end.join("\n") + + variables = Ci::GroupVariable + .where("group_id IN (#{list_of_ids.join(", ")})") + .order("CASE group_id #{order} END DESC") + project.protected_for?(ref) ? variables : variables.unprotected end |