diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /app/models/ci/build.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r-- | app/models/ci/build.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 74a329dccf4..8bc75b6c164 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -4,7 +4,6 @@ module Ci class Build < Ci::Processable include Ci::Metadatable include Ci::Contextable - include Ci::PipelineDelegator include TokenAuthenticatable include AfterCommitQueue include ObjectStorage::BackgroundMove @@ -526,6 +525,7 @@ module Ci strong_memoize(:variables) do Gitlab::Ci::Variables::Collection.new .concat(persisted_variables) + .concat(job_jwt_variables) .concat(scoped_variables) .concat(job_variables) .concat(environment_changed_page_variables) @@ -591,13 +591,7 @@ module Ci def merge_request strong_memoize(:merge_request) do - merge_requests = MergeRequest.includes(:latest_merge_request_diff) - .where(source_branch: ref, source_project: pipeline.project) - .reorder(iid: :desc) - - merge_requests.find do |merge_request| - merge_request.commit_shas.include?(pipeline.sha) - end + pipeline.all_merge_requests.order(iid: :asc).first end end @@ -981,6 +975,15 @@ module Ci def has_expiring_artifacts? artifacts_expire_at.present? && artifacts_expire_at > Time.now end + + def job_jwt_variables + Gitlab::Ci::Variables::Collection.new.tap do |variables| + break variables unless Feature.enabled?(:ci_job_jwt, project, default_enabled: true) + + jwt = Gitlab::Ci::Jwt.for_build(self) + variables.append(key: 'CI_JOB_JWT', value: jwt, public: false, masked: true) + end + end end end |