Commit af46d33f authored by Jason van den Hurk's avatar Jason van den Hurk

Added the CI_REF_PROTECTED variable to the Gitlab runner

This variable shows if the branch the runner is executing is protected
or not.
References: #50909
parent e861af40
...@@ -638,6 +638,7 @@ module Ci ...@@ -638,6 +638,7 @@ module Ci
variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s) variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s)
variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s) variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s)
variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s) variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s)
variables.append(key: 'CI_REF_PROTECTED', value: protected_ref?.to_s)
if merge_request_event? && merge_request if merge_request_event? && merge_request
variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA', value: source_sha.to_s) variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA', value: source_sha.to_s)
......
...@@ -33,7 +33,7 @@ describe Ci::Bridge do ...@@ -33,7 +33,7 @@ describe Ci::Bridge do
CI_PROJECT_ID CI_PROJECT_NAME CI_PROJECT_PATH CI_PROJECT_ID CI_PROJECT_NAME CI_PROJECT_PATH
CI_PROJECT_PATH_SLUG CI_PROJECT_NAMESPACE CI_PIPELINE_IID CI_PROJECT_PATH_SLUG CI_PROJECT_NAMESPACE CI_PIPELINE_IID
CI_CONFIG_PATH CI_PIPELINE_SOURCE CI_COMMIT_MESSAGE CI_CONFIG_PATH CI_PIPELINE_SOURCE CI_COMMIT_MESSAGE
CI_COMMIT_TITLE CI_COMMIT_DESCRIPTION CI_COMMIT_TITLE CI_COMMIT_DESCRIPTION CI_REF_PROTECTED
] ]
expect(bridge.scoped_variables_hash.keys).to include(*variables) expect(bridge.scoped_variables_hash.keys).to include(*variables)
......
...@@ -2227,7 +2227,8 @@ describe Ci::Build do ...@@ -2227,7 +2227,8 @@ describe Ci::Build do
{ key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true, masked: false }, { key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true, masked: false },
{ key: 'CI_COMMIT_MESSAGE', value: pipeline.git_commit_message, public: true, masked: false }, { key: 'CI_COMMIT_MESSAGE', value: pipeline.git_commit_message, public: true, masked: false },
{ key: 'CI_COMMIT_TITLE', value: pipeline.git_commit_title, public: true, masked: false }, { key: 'CI_COMMIT_TITLE', value: pipeline.git_commit_title, public: true, masked: false },
{ key: 'CI_COMMIT_DESCRIPTION', value: pipeline.git_commit_description, public: true, masked: false } { key: 'CI_COMMIT_DESCRIPTION', value: pipeline.git_commit_description, public: true, masked: false },
{ key: 'CI_REF_PROTECTED', value: pipeline.protected_ref?.to_s, public: true, masked: false }
] ]
end end
......
...@@ -670,7 +670,8 @@ describe Ci::Pipeline, :mailer do ...@@ -670,7 +670,8 @@ describe Ci::Pipeline, :mailer do
CI_PIPELINE_SOURCE CI_PIPELINE_SOURCE
CI_COMMIT_MESSAGE CI_COMMIT_MESSAGE
CI_COMMIT_TITLE CI_COMMIT_TITLE
CI_COMMIT_DESCRIPTION] CI_COMMIT_DESCRIPTION
CI_REF_PROTECTED]
end end
context 'when source is merge request' do context 'when source is merge request' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment