Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita42abeb

Browse files
authored
Update variables with new design (#1123)
* Update variables with new design* Update variable contentAdded new secret option for variable
1 parentf525ee8 commita42abeb

File tree

6 files changed

+84
-66
lines changed

6 files changed

+84
-66
lines changed

‎_docs/pipelines/variables.md‎

Lines changed: 84 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ redirect_from:
77
-/docs/codefresh-yaml/variables/
88
toc:true
99
---
10-
Variables in pipelines allow you to parameterize the way your pipeline works. Codefresh provides a set of system variables, and the capability to define custom variables.
10+
Variables in pipelines allow you to parameterize the way your pipeline works.
11+
Codefresh provides a set of system variables, and also provides the capability to define custom variables.
1112

1213
*[System variables](#system-variables) are predefined variables prefixed with`CF`.
1314
System variables are automatically included in every pipeline build. Here are some examples of system variables.
@@ -16,15 +17,16 @@ Variables in pipelines allow you to parameterize the way your pipeline works. Co
1617
*`CF_BUILD_URL` is the url of the pipeline build.
1718

1819
*[User-defined variables](#user-defined-variables) are custom variables which you create.
19-
You can create user-defined variables for different entities in Codefresh, such as projects, pipelines and steps, with or without a default value. You can also import variables you may have already defined.
20+
You can create user-defined variables for different entities such as projects, pipelines and steps, with or without default values. You can also import variables you may have already defined.
21+
2022

2123
Codefresh supports[two syntaxes](#using-codefresh-variables-in-pipelines) for variables: the UNIX syntax, and a proprietary syntax for use in YAML files.
2224

2325
##Using Codefresh variables in pipelines
2426

2527
There are two ways to use a Codefresh variable in your pipelines:
2628

27-
1. Expose as UNIX environment variables
29+
1. Expose as UNIX environment variables
2830
This is the default method. All variables in all[`freestyle`]({{site.baseurl}}/docs/pipelines/steps/freestyle/) steps are exposed as UNIX environment variables. For example,`$MY_VARIABLE_EXAMPLE`.
2931
1. Directly in YAML properties
3032
This format, specific to Codefresh, can be used in in YAML properties with the syntax {% raw %}`${{MY_VARIABLE_EXAMPLE}}`{% endraw %}.
@@ -53,7 +55,7 @@ MyOwnStep:
5355
5456
{% endraw %}
5557
56-
### Example: Use directly in YAML properties
58+
### Example: Usevariabledirectly in YAML properties
5759
5860
`YAML`
5961
{% raw %}
@@ -99,6 +101,7 @@ feature-vb145dh
99101

100102
System variables are automatically injected to any freestyle step as environment variables.
101103

104+
##### Git-based system variables
102105
The values of Git-based system variables, such as `CF_BRANCH`, `CF_COMMIT_MESSAGE`, `CF_REVISION` etc. are retrieved directly from the Git provider you use, and therefore have the same limitations of that provider.
103106

104107
For example, GitLab sends less information in Pull Request (PR) events than normal pushes, and Bitbucket sends only the short hash of a commit in PR events. We suggest you read the documentation of your Git provider first to understand what information is available for every Git event.
@@ -261,67 +264,113 @@ Gerrit has no explicit concept of PRs as in other version control systems to map
261264

262265
## User-defined variables
263266

264-
User-defined variables are custom variables you add to Codefresh entities such as projects, pipelines, build triggers, and manual build runs.
265-
You create such variables manually or by importing predefined variables from files (see [How to](#create-user-defined-variables)). You can also create empty variables, without any values.
267+
User-defined variables are custom variables you add to CI entities such as projects, pipelines, build triggers, and manual build runs.
268+
When adding a user-defined variable, you can create a:
269+
270+
* **Variable**
271+
A standard variable whose value is visible in plain text unless explicitly encrypted. You can create these manually, import them from a file with predefined values, or define empty variables without assigned values.
272+
* **Secret**
273+
A variable whose value is automatically encrypted and masked in logs.
274+
275+
276+
277+
### Methods to define user-defined variables
278+
279+
These are the options available to add user-defined variables.
280+
281+
* **Add single variable**
282+
Supported for all entities, this method allows you to add one variable at a time, with or without values.
283+
You cannot encrypt empty variables.
284+
* **Add multiple variables**
285+
Add a set of variables by entering them manually, or by pasting them into the variable editor, one variable per line.
286+
This is a quick option to add variables defined locally or in specific environments to a pipeline.
287+
You simply copy the set of variables and paste them into the text editor.
288+
* **Import from file**
289+
Add predefined variables in bulk by importing from a file.
266290

267291
### Empty user-defined variables
268292

269-
Codefresh allowsyoutoadd variables with just the key definitions,without values. The valuesare automatically populated during pipeline execution or defined manually.
293+
Ifyou add variables with just the key definitions,the valuesare automatically populated during pipeline execution orcan bedefined manually prior to build runs.
270294
You can add empty variables to:
271-
272295
* Projects
273296
* Pipelines
274297
* Build triggers
275298

276299
> **NOTE**
277300
> Encryption is not supported for empty variables.
278301

279-
### Import user-defined variables in bulk
280-
281-
Add custom variables in bulk by pasting them into the text editor or by importing them from a file.
282-
283-
* Import from text
284-
This is a quick option to add variables defined locally or in specific environments to a pipeline.
285-
You simply copy the set of variables and paste them into the text editor.
286302

287-
* Import from file
288-
Importing from a file is useful when you have a file containing the predefined variables.
289303

290304
### Order of precedence for user-defined variables
291305

292-
In Codefresh, becuase you can add user-defined variables to different entities, variable definitions are available at levels.
293-
294-
If the variable with the same name is defined at multiple levels, the override rules are based on the priority of the variable. Variables at levels with higher priority override those at levels with lower priority.
306+
Because you can add user-defined variables to different entities, you can have the same variables at different levels.
307+
If the variable with the same name is defined for multiple entities, the override rules are based on the priority of the variable. Variables for entities with higher priority override those for entities with lower priority.
295308

296309
For example if a pipeline variable is defined both within a project, and as an execution parameter of a specific build, the final result will be the value of the variable defined as a build parameter. The project-level variable is ignored.
297310

298311
Listed below are the different levels for user-defined variables in order of priority, from the highest to the lowest.
299312

300-
1. Steps
313+
1.**Steps**
301314
* `export` command
302315
Within the current step using [`export`](http://linuxcommand.org/lc3_man_pages/exporth.html){:target="\_blank"}, or in any **subsequent** step using [cf_export](#exporting-variables-with-cf_export) commands.
303316
* [`freestyle`]({{site.baseurl}}/docs/pipelines/steps/freestyle/#examples) steps with `environment` field.
304317

305318
> **NOTE**
306319
> Step-level variables with `export` take precedence over freestyle-step variables with `environment`.
307-
1. Builds
320+
1.**Builds**
308321
* Within a specific build execution from the Codefresh UI or from the [CLI]({{site.baseurl}}/docs/integrations/codefresh-api/#example---triggering-pipelines).
309-
1. Pipeline
322+
1.**Pipeline**
310323
1. [Shared-configurations]({{site.baseurl}}/docs/pipelines/configuration/shared-configuration/)
311-
1. Projects
324+
1.**Projects**
312325

313326
The variables are injected into pipelines from different sources and at different levels. To view the variables actually used by a specific build of the pipeline, see [Viewing variables in pipeline builds]({{site.baseurl}}/docs/pipelines/monitoring-pipelines/#viewing-variables-in-pipeline-builds).
314327

315-
### Create user-defined variables
316328

317-
Create user-defined variables by selecting the target entity and then adding the variables.
318329

319-
#### Step 1: Select entity to which to add variables
330+
### Add user-defined variables
331+
332+
1. Select the entity to which to add variables:
333+
* [Projects](#projects)
334+
* [Pipelines](#pipelines)
335+
* [Steps](#steps)
336+
* [Builds](#builds)
337+
1. Select the type of variable to add:**Variable** or **Secret**.
338+
339+
{% include
340+
image.html
341+
lightbox="true"
342+
file="/images/pipeline/variables/add-secret-variable-option.png"
343+
url="/images/pipeline/variables/add-secret-variable-option.png"
344+
alt="Add user-defined variables or secrets"
345+
caption="Add user-defined variables or secrets"
346+
max-width="60%"
347+
%}
320348

321-
You can create user-defined variables for projects, pipelines, build runs, and steps.
322349

323-
* **Projects**
324-
In the row with the Project to which to add variables, click the **Settings** icon, and then click the **Variables** tab.
350+
**Standard variables**
351+
* Add single or multiple variables manually as key-value pairs, or import them in bulk from a file.
352+
* To encrypt a variable, click {::nomarkdown}<img src="../../../images/icons/encrypt.png" display=inline-block alt="lock icon"> <b>Encrypt</b>{:/}, and confirm.
353+
354+
{% include
355+
image.html
356+
lightbox="true"
357+
file="/images/pipeline/variables/add-variable-form.png"
358+
url="/images/pipeline/variables/add-variable-form.png"
359+
alt="Options to add standard variables"
360+
caption="Options to add standard variables"
361+
max-width="60%"
362+
%}
363+
364+
* **Secret variables**
365+
* Secrets are automatically encrypted and become immutable once saved.
366+
* Decrypting a secret resets its value to empty.
367+
368+
369+
370+
371+
372+
##### Projects
373+
From the list of **Projects**, select the Project to which to add variables, click the **Settings** icon, and then click the **Variables** tab.
325374

326375
{% include
327376
image.html
@@ -333,9 +382,9 @@ You can create user-defined variables for projects, pipelines, build runs, and s
333382
max-width="60%"
334383
%}
335384

336-
* **Pipelines**
337-
* In therow withthe Pipeline to which to add variables, click the **Settings** icon.
338-
* Ontheright,click **Variables**.
385+
#####Pipelines
386+
* From thelist of pipelines, selectthe Pipeline to which to add variables.
387+
* Click the **Settings** icon, clickthe**Workflow** tab, and thenclick **Variables** on the right.
339388

340389
{% include
341390
image.html
@@ -347,11 +396,11 @@ You can create user-defined variables for projects, pipelines, build runs, and s
347396
max-width="60%"
348397
%}
349398

350-
* **Steps**
399+
#####Steps
351400
* Select the pipeline.
352401
* In the **Workflow** tab, add the variable with the correct syntax to the step as required.
353402

354-
* **Builds**
403+
#####Builds
355404
* From the Builds page, in the Pipelines column, click the pipeline name.
356405
* Click **Run**.
357406
* Expand Build Variables.
@@ -366,42 +415,11 @@ You can create user-defined variables for projects, pipelines, build runs, and s
366415
max-width="60%"
367416
%}
368417

369-
#### Step 2: Add variables
370418

371-
Add variables manually by defining them as key-value pairs, or by importing them from files.
372419

373-
When adding variables, manually or through import, you can add/include empty variables, that is add only the key for the variable and leave the value empty to be dynamically or manually populated.
374-
Apart from empty variables, you can also encrypt sensitive variables for reasons of security.
375420

376-
1. To manually add variables, click **Add Variable**.
377-
* To add the variable with its default value, enter the key-value pair.
378-
* To add an empty variable without a default value, simply type the key.
379421

380-
{% include
381-
image.html
382-
lightbox="true"
383-
file="/images/pipeline/variables/example-empty-variable.png"
384-
url="/images/pipeline/variables/example-empty-variable.png"
385-
alt="Example of empty variable in project"
386-
caption="Example of empty variable in project"
387-
max-width="60%"
388-
%}
389422

390-
{:start="2"}
391-
1. (Applies only to projects and pipelines) To import by copy and paste, click **Import from Text**:
392-
* Copy the set of variables to add.
393-
* Paste into the text editor.
394-
* Click **Import**
395-
{:start="3"}
396-
1. (Applies only to projects and pipelines) To import them from a file, click **Import from File**:
397-
* Browse to the file to import, and then click **Import**.
398-
399-
<!-- markdownlint-disable MD033 -->
400-
{:start="4"}
401-
1. Click **Save**.
402-
1. To encrypt the variables (not supported for empty variables), click {::nomarkdown}<img src="../../../images/icons/encrypt.png" display=inline-block alt="lock icon"> <b>Encrypt</b>{:/}, and confirm.
403-
404-
<!-- markdownlint-enable MD033 -->
405423

406424
## Exporting environment variables from a freestyle step
407425

27.7 KB
Loading
49.4 KB
Loading
-55.5 KB
Loading
-51.6 KB
Loading
-79.3 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp