You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* don't error for links to support site
* Fix Vale errors in env-vars.adoc
Resolved the following Vale errors:
- Lines 11,13,20,25,27,41-46,125,159,180,249,274-275,279,284,289-291: XrefTitleCase - Updated all xref link texts to title case
- Lines 50,107: ImageTitles - Added missing image titles
- Line 109: Avoid 'am' - Rewrote prose to avoid quoting step name containing 'am'
- Line 206: Avoid 'were' - 'as if they were defined' → 'as if they are defined'
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: docs/guides/modules/security/pages/env-vars.adoc
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,23 +8,23 @@
8
8
9
9
Use environment variables to set up various configuration options, and keep your set-up secure with secrets, private keys, and contexts. Environment variables in CircleCI are governed by an <<order-of-precedence,order of precedence>>, allowing control at each level in your configuration.
10
10
11
-
See the xref:set-environment-variable.adoc[Set an environment variable] page for guidance on the different ways to set an environment variable.
11
+
See the xref:set-environment-variable.adoc[Set an Environment Variable] page for guidance on the different ways to set an environment variable.
12
12
13
-
If you have existing environment variables (or contexts) and you would like to rename your organization or repository, follow the xref:rename-organizations-and-repositories.adoc[Rename organizations and repositories] guide. The recommended steps ensure you do not lose access to environment variables or contexts in the process.
13
+
If you have existing environment variables (or contexts) and you would like to rename your organization or repository, follow the xref:rename-organizations-and-repositories.adoc[Rename Organizations and Repositories] guide. The recommended steps ensure you do not lose access to environment variables or contexts in the process.
14
14
15
15
[#built-in-environment-variables]
16
16
== Built-in environment variables
17
17
18
18
All projects have access to CircleCI's built-in environment variables. These environment variables are scoped at the job level, so they can be used with the `context` key in a job, but they do not exist at a pipeline level.
19
19
20
-
For a full list of built-in environment variables, see the xref:reference:ROOT:variables.adoc#built-in-environment-variables[Project values and variables] page.
20
+
For a full list of built-in environment variables, see the xref:reference:ROOT:variables.adoc#built-in-environment-variables[Project Values and Variables] page.
21
21
22
22
[#private-keys-and-secrets]
23
23
== Private keys and secrets
24
24
25
-
To add private keys or secrets as environment variables for use throughout your project, navigate to menu:Project Settings[Environment Variables] in the link:https://app.circleci.com/[CircleCI web app]. You can find step-by-step instructions of this process on the xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Environment variables] page. The variable values are neither readable nor editable in the app after they are set. To change the value of an environment variable, delete the current variable, and add it again with the new value.
25
+
To add private keys or secrets as environment variables for use throughout your project, navigate to menu:Project Settings[Environment Variables] in the link:https://app.circleci.com/[CircleCI web app]. You can find step-by-step instructions of this process on the xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Environment Variables] page. The variable values are neither readable nor editable in the app after they are set. To change the value of an environment variable, delete the current variable, and add it again with the new value.
26
26
27
-
Private environment variables enable you to store secrets safely, even when your project is public. Refer to the xref:integration:oss.adoc[Building open source projects] page for associated security and settings information.
27
+
Private environment variables enable you to store secrets safely, even when your project is public. Refer to the xref:integration:oss.adoc[Building Open Source Projects] page for associated security and settings information.
@@ -38,15 +38,16 @@ CircleCI uses Bash, which follows the POSIX naming convention for environment va
38
38
39
39
Environment variables are used according to a specific precedence order, as follows:
40
40
41
-
. Environment variables declared xref:set-environment-variable.adoc#set-an-environment-variable-in-a-shell-command[inside a shell command] in a `run` step, for example `FOO=bar make install`.
42
-
. Environment variables declared with the `environment` key xref:set-environment-variable.adoc#set-an-environment-variable-in-a-step[for a `run` step].
43
-
. Environment variables set with the `environment` key xref:set-environment-variable.adoc#set-an-environment-variable-in-a-job[for a job].
44
-
. Special CircleCI environment variables defined in the xref:reference:ROOT:variables.adoc#built-in-environment-variables[CircleCI Built-in environment variables] document.
41
+
. Environment variables declared xref:set-environment-variable.adoc#set-an-environment-variable-in-a-shell-command[Inside a Shell Command] in a `run` step, for example `FOO=bar make install`.
42
+
. Environment variables declared with the `environment` key xref:set-environment-variable.adoc#set-an-environment-variable-in-a-step[For a `run` Step].
43
+
. Environment variables set with the `environment` key xref:set-environment-variable.adoc#set-an-environment-variable-in-a-job[For a Job].
44
+
. Special CircleCI environment variables defined in the xref:reference:ROOT:variables.adoc#built-in-environment-variables[CircleCI Built-in Environment Variables] document.
45
45
. Context environment variables (assuming the user has access to the context). See the xref:contexts.adoc[Contexts] documentation for more information.
46
-
. xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project-level environment variables] set on the *Project Settings* page in the web app.
46
+
. xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project-Level Environment Variables] set on the *Project Settings* page in the web app.
47
47
48
48
Environment variables declared inside a shell command `run` step, for example `FOO=bar make install`, will override environment variables declared with the `environment` and `contexts` keys. Environment variables added on the *Contexts* page in the web app will take precedence over variables added on the *Project Settings* page.
49
49
50
+
.Environment variable order of precedence
50
51
image::guides:ROOT:env-var-order.png[Environment variable order of precedence]
51
52
52
53
[#example-configuration-of-environment-variables]
@@ -104,9 +105,10 @@ The above `.circleci/config.yml` demonstrates the following:
104
105
105
106
When the above configuration runs, the output looks like the image below. Notice the environment variables stored in the project is masked, and displays as `+****+`:
Notice there are two similar steps in the above image and configuration - "What branch am I on?" These steps illustrate two different methods to read environment variables.
111
+
Notice there are two similar steps in the above image and configuration - both checking the current branch name. These steps illustrate two different methods to read environment variables.
110
112
111
113
In the example configuration above, two syntax variants are used: `+${VAR}+` and `$VAR`. Both syntax variants are supported. You can read more about shell parameter expansion in the link:https://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion[Bash documentation].
112
114
@@ -122,7 +124,7 @@ In the example below, `$ORGNAME` and `$REPONAME` will not be interpolated.
NOTE: An exception to this interpolation rule is using project environment variables to pull xref:execution-managed:private-images.adoc[private images].
127
+
NOTE: An exception to this interpolation rule is using project environment variables to pull xref:execution-managed:private-images.adoc[Private Images].
126
128
127
129
You can reuse pieces of configuration across your `.circleci/config.yml` file. By using the `parameters` declaration, you can pass values into reusable `commands`, `jobs`, and `executors`:
128
130
@@ -156,7 +158,7 @@ workflows:
156
158
repo_name: project2
157
159
----
158
160
159
-
For more information, read the documentation on xref:reference:ROOT:reusing-config.adoc#using-the-parameters-declaration[using the parameters declaration].
161
+
For more information, read the documentation on xref:reference:ROOT:reusing-config.adoc#using-the-parameters-declaration[Using the Parameters Declaration].
160
162
161
163
Another possible method to interpolate values into your configuration is to use a `run` step to export environment variables to `BASH_ENV`, as shown below.
162
164
@@ -177,7 +179,7 @@ In every step, CircleCI uses `bash` to source `BASH_ENV`. This means that `BASH_
177
179
[#environment-variable-substitution]
178
180
=== Environment variable substitution
179
181
180
-
The CircleCI environment CLI offers a wrapper around the link:https://github.com/a8m/envsubst[`envsubst`] tool, available both locally as well as in all jobs running on CircleCI. `envsubst` is a command-line utility used to replace environment variables in text strings. You can also refer to the full xref:toolkit:environment-cli-usage-guide.adoc[Environment CLI usage guide].
182
+
The CircleCI environment CLI offers a wrapper around the link:https://github.com/a8m/envsubst[`envsubst`] tool, available both locally as well as in all jobs running on CircleCI. `envsubst` is a command-line utility used to replace environment variables in text strings. You can also refer to the full xref:toolkit:environment-cli-usage-guide.adoc[Environment CLI Usage Guide].
181
183
182
184
CLI command:
183
185
@@ -203,7 +205,7 @@ Within your repository create a file such as `template.json`, with value replace
203
205
204
206
`envsubst` can convert all types of environment variable strings, including those encased in curly braces (`{}`).
205
207
206
-
The config example below shows the corresponding environment variables as if they were defined directly within a step in the config. However, we strongly recommend creating the environment variables in the CircleCI app, either in xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project Settings] or as a xref:contexts.adoc[context].
208
+
The config example below shows the corresponding environment variables as if they are defined directly within a step in the config. However, we strongly recommend creating the environment variables in the CircleCI app, either in xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project Settings] or as a xref:contexts.adoc[context].
207
209
208
210
[,yaml]
209
211
----
@@ -246,7 +248,7 @@ Output:
246
248
}
247
249
----
248
250
249
-
For instructions on installing the CircleCI CLI locally, read the xref:toolkit:local-cli.adoc[Installing the CircleCI local CLI] guide.
251
+
For instructions on installing the CircleCI CLI locally, read the xref:toolkit:local-cli.adoc[Installing the CircleCI Local CLI] guide.
250
252
251
253
[#alpine-linux]
252
254
=== Alpine Linux
@@ -271,21 +273,21 @@ jobs:
271
273
272
274
Do not add secrets or keys inside the `.circleci/config.yml` file. The full text of `.circleci/config.yml` is visible to developers with access to your project on CircleCI. Store secrets or keys in the CircleCI web app under one of the following:
273
275
274
-
* In xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project settings].
275
-
* In a xref:set-environment-variable.adoc#set-an-environment-variable-in-a-context[context].
276
+
* In xref:set-environment-variable.adoc#set-an-environment-variable-in-a-project[Project Settings].
277
+
* In a xref:set-environment-variable.adoc#set-an-environment-variable-in-a-context[Context].
276
278
277
279
For more information, see the xref:security.adoc#encryption[Encryption] section of the security page.
278
280
279
-
Running scripts within configuration may expose secret environment variables. See the xref:orchestrate:using-shell-scripts.adoc#shell-script-best-practices[Using shell scripts] page for best practices for secure scripts.
281
+
Running scripts within configuration may expose secret environment variables. See the xref:orchestrate:using-shell-scripts.adoc#shell-script-best-practices[Using Shell Scripts] page for best practices for secure scripts.
280
282
281
283
[#contexts]
282
284
== Contexts
283
285
284
-
You can further restrict access to environment variables using xref:contexts.adoc[contexts]. Contexts are set from the *Organization Settings* in the CircleCI web app.
286
+
You can further restrict access to environment variables using xref:contexts.adoc[Contexts]. Contexts are set from the *Organization Settings* in the CircleCI web app.
0 commit comments