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
Copy file name to clipboardExpand all lines: jekyll/_cci2/inject-environment-variables-with-api.adoc
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The example below triggers a pipeline with parameter values for `workingdir` and
27
27
NOTE: In order to pass a parameter when triggering a pipeline via the API, the parameter must be <<reusing-config#using-the-parameters-declaration,declared in the configuration file>>.
28
28
29
29
```shell
30
-
curl -u ${CIRCLECI_TOKEN}: -X POST --header "Content-Type: application/json" -d '{
30
+
curl -u ${CIRCLE_TOKEN}: -X POST --header "Content-Type: application/json" -d '{
Copy file name to clipboardExpand all lines: jekyll/_cci2/pipeline-variables.md
+43-49Lines changed: 43 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,29 @@
1
1
---
2
2
layout: classic-docs
3
3
title: Pipeline values and parameters
4
-
description: "Detailed information about pipeline parameters and values"
4
+
description: "Information about pipeline parameters and values and how to use them."
5
5
categories: [getting-started]
6
-
order: 1
7
6
contentTags:
8
7
platform:
9
8
- Cloud
10
9
- Server v4.x
11
10
- Server v3.x
12
11
---
13
12
13
+
## Introduction
14
+
{: #introduction}
15
+
14
16
Pipeline values and parameters can be used to create reusable pipeline configurations.
15
17
16
18
***Pipeline values** represent pipeline metadata that can be used throughout the configuration.
17
-
***Pipeline parameters** are typed pipeline variables that are declared in the `parameters` key at the top level of a configuration. Users can pass `parameters` into their pipelines when triggering a new run of a pipeline through the API.
19
+
***Pipeline parameters** are typed pipeline variables that are declared in the `parameters` key at the top level of a configuration. Users can pass `parameters` into their pipelines when triggering a new run of a pipeline through the API or web app.
18
20
19
21
## Pipeline values
20
22
{: #pipeline-values }
21
23
22
24
Pipeline values are available to all pipeline configurations and can be used without previous declaration.
23
25
24
-
For a full list of values and built-in environment variables, see the [Project Values and Variables guide]({{site.baseurl}}/variables/#pipeline-values).
26
+
For a full list of values and built-in environment variables, see the [Project values and variables](/docs/variables/#pipeline-values) guide.
25
27
26
28
{% include snippets/pipeline-values.md %}
27
29
@@ -45,28 +47,28 @@ jobs:
45
47
- run: echo $CIRCLE_COMPARE_URL
46
48
```
47
49
48
-
When using the above method to set the values in the `environment` key, note that if the pipeline variable is empty it will be set to `<nil>`. If you need an empty string instead, [set the variable in a shell command]({{ site.baseurl }}/set-environment-variable/#set-an-environment-variable-in-a-shell-command).
50
+
When using the above method to set the values in the `environment` key, note that if the pipeline variable is empty it will be set to `<nil>`. If you need an empty string instead, [set the variable in a shell command](/docs/set-environment-variable/#set-an-environment-variable-in-a-shell-command).
49
51
{: class="alert alert-info" }
50
52
51
53
## Pipeline parameters in configuration
52
54
{: #pipeline-parameters-in-configuration }
53
55
54
-
Pipeline parameters are declared using the `parameters` key at the top level of a `.circleci/config.yml` file.
56
+
Pipeline parameters are declared using the `parameters` key at the top level of a `.circleci/config.yml` file. Pipeline parameters can be referenced by value and used as a configuration variable under the scope `pipeline.parameters`.
55
57
56
58
Pipeline parameters support the following types:
59
+
57
60
* string
58
61
* boolean
59
62
* integer
60
63
* enum
61
64
62
-
See [Parameter Syntax]({{ site.baseurl }}/reusing-config/#parameter-syntax) for usage details.
63
-
64
-
Pipeline parameters can be referenced by value and used as a config variable under the scope `pipeline.parameters`.
65
+
See [Parameter syntax](/docs/reusing-config/#parameter-syntax) for usage details.
65
66
66
-
The example below shows a configuration with two pipeline parameters (`image-tag` and `workingdir`) defined at the top of the config, and then subsequently referenced in the `build` job:
67
+
The example below shows a configuration with two pipeline parameters (`image-tag` and `workingdir`) defined at the top of the configuration, and then subsequently referenced in the `build` job:
67
68
68
69
```yaml
69
70
version: 2.1
71
+
70
72
parameters:
71
73
image-tag:
72
74
type: string
@@ -95,12 +97,13 @@ jobs:
95
97
96
98
A pipeline can be triggered with specific `parameter` values using the API v2 endpoint to [trigger a pipeline](https://circleci.com/docs/api/v2/#trigger-a-new-pipeline). This can be done by passing a `parameters` key in the JSON packet of the `POST` body.
97
99
98
-
**Note:** Please note that the `parameters` key passed in this `POST` request is **NOT** secret.
100
+
The `parameters` key passed in this `POST` request is **NOT** secret.
101
+
{: class="alert alert-warning" }
99
102
100
-
The example below triggers a pipeline with the parameters described in the above config example (NOTE: To pass a parameter when triggering a pipeline via the API the parameter must be declared in the configuration file.).
103
+
The example below triggers a pipeline with the parameters described in the above configuration example. If you run a command to trigger a pipeline, and the parameter has not been declared in the configuration file, you will receive an error response message, such as `Project not found`.
101
104
102
105
```shell
103
-
curl -u ${CIRCLECI_TOKEN}: -X POST --header "Content-Type: application/json" -d '{
106
+
curl -u ${CIRCLE_TOKEN}: -X POST --header "Content-Type: application/json" -d '{
In addition to using the CLI and API, you can also trigger a pipeline with parameters from the CircleCI web app. To do this:
115
-
116
-
1. Navigate to the dashboard view in the web app.
117
-
2. Use the project filter to select the desired project.
118
-
3. Use the branch filter to select the branch on which you want to run the new pipeline.
119
-
4. Click the **Trigger Pipeline** button (towards the top right corner of the page).
120
-
5. Use the **Add Parameters** dropdown to specify the type, name, and value of your desired parameters.
121
-
6. Click **Trigger Pipeline**.
117
+
In addition to using the API, you can also trigger a pipeline with parameters from the CircleCI web app. If you pass a parameter when triggering a pipeline from the web app, and the parameter has not been declared in the configuration file, the pipeline will fail with the error `Unexpected argument(s)`.
122
118
123
-
**NOTE:** If you pass a parameter when triggering a pipeline from the web app, and the parameter has not been declared in the configuration file, the pipeline will fail with the error `Unexpected argument(s)`)
124
-
125
-
126
-
## The scope of pipeline parameters
127
-
{: #the-scope-of-pipeline-parameters }
119
+
1. Use the project filter to select the desired project.
120
+
2. Use the branch filter to select the branch on which you want to run the new pipeline.
121
+
3. Click the **Trigger Pipeline** button (towards the top right corner of the page).
122
+
4. Use the **Add Parameters** dropdown to specify the type, name, and value of your desired parameters.
123
+
5. Click **Trigger Pipeline**.
128
124
129
-
Pipeline parameters can only be resolved in the `.circleci/config.yml` file in which they are declared. Pipeline parameters are not available in orbs, including orbs declared locally in your config.yml file. This was done because access to the pipeline scope in orbs would break encapsulation and create a hard dependency between the orb and the calling config, potentially jeopardizing determinism and creating a surface area of vulnerability.
125
+
Parameters can also be called when setting up a scheduled pipeline in the web app. The parameters are part of the trigger form in **Project Settings > Triggers**. Any parameter set up as a part of a scheduled pipeline will also need to be declared in the configuration file, otherwise the the pipeline will fail with the error `Unexpected argument(s)`.
Configuration processing happens in the following stages:
139
131
@@ -143,10 +135,15 @@ Configuration processing happens in the following stages:
143
135
144
136
The remaining configuration is processed, element parameters are resolved, type-checked, and substituted.
145
137
146
-
## Element parameter scope
138
+
## The scope of pipeline parameters
139
+
{: #the-scope-of-pipeline-parameters }
140
+
141
+
Pipeline parameters can only be resolved in the `.circleci/config.yml` file in which they are declared. Pipeline parameters are not available in orbs, including orbs declared locally in your `.circleci/config.yml` file. This is because access to pipeline scope in orbs would break encapsulation and create a hard dependency between the orb and the calling configuration. This would potentially create a surface area of vulnerability, increasing security risks.
142
+
143
+
### Element parameter scope
147
144
{: #element-parameter-scope }
148
145
149
-
Element parameters use lexical scoping, so parameters are in scope within the element they are defined in, e.g. a job, a command, or an executor. If an element with parameters calls another element with parameters, like in the example below, the inner element does not inherit the scope of the calling element.
146
+
Element parameters use lexical scoping, so parameters are in scope within the element they are defined in, for example, a job, a command, or an executor. If an element with parameters calls another element with parameters, like in the example below, the inner element does not inherit the scope of the calling element.
150
147
151
148
```yaml
152
149
version: 2.1
@@ -160,25 +157,25 @@ commands:
160
157
- run: echo << parameters.message >>
161
158
162
159
jobs:
163
-
cat-file:
160
+
daily-message:
161
+
machine: true
164
162
parameters:
165
-
file:
163
+
message:
166
164
type: string
167
165
steps:
168
166
- print:
169
-
message: Printing << parameters.file >>
170
-
- run: cat << parameters.file >>
167
+
message: Printing << parameters.message >>
171
168
172
169
workflows:
173
170
my-workflow:
174
171
jobs:
175
-
- cat-file:
176
-
file: test.txt
172
+
- daily-message:
173
+
message: echo << parameters.message >>
177
174
```
178
175
179
-
Even though the `print` command is called from the cat-file job, the file parameter would not be in scope inside the print. This ensures that all parameters are always bound to a valid value, and the set of available parameters is always known.
176
+
Even though the `print` command is called from the `cat-file` job, the file parameter would not be in scope inside the print job. This ensures that all parameters are always bound to a valid value, and the set of available parameters is always known. Running this would throw a pipeline error of `Arguments referenced without declared parameters: message`.
180
177
181
-
## Pipeline value scope
178
+
### Pipeline value scope
182
179
{: #pipeline-value-scope }
183
180
184
181
Pipeline values, the pipeline-wide values that are provided by CircleCI (e.g. `<< pipeline.number >>`) are always in scope.
@@ -194,11 +191,9 @@ Pipeline parameters which are defined in configuration are always in scope, with
194
191
## Conditional workflows
195
192
{: #conditional-workflows }
196
193
197
-
Use the [`when` clause]({{site.baseurl}}/configuration-reference/#using-when-in-workflows) (or the inverse clause `unless`) under a workflow declaration, along with a [logic statement]({{site.baseurl}}/configuration-reference/#logic-statements), to decide whether or not to run that workflow. Logic statements in a `when` or `unless` clause should evaluate to a truthy or falsy value.
198
-
199
-
The most common use of this construct is to use a pipeline parameter as the value, allowing an API trigger to pass that parameter to determine which workflows to run.
194
+
Use the [`when` clause](/docs/configuration-reference/#using-when-in-workflows) (or the inverse clause `unless`) under a workflow declaration, along with a [logic statement](/docs/configuration-reference/#logic-statements), to decide whether or not to run that workflow. Logic statements in a `when` or `unless` clause should evaluate to a truthy or falsy value.
200
195
201
-
Below is an example configuration using the pipeline parameter `run_integration_tests` to drive whether the workflow `integration_tests` will run.
196
+
The most common use of this construct is to use a pipeline parameter as the value, allowing a trigger to pass that parameter to determine which workflows to run. Below is an example configuration using the pipeline parameter `run_integration_tests` to set whether the workflow `integration_tests` will run.
The example shown above prevents the workflow `integration_tests` from being triggered unless it is explicitly invoked when the pipeline is triggered with the following in the `POST` body:
219
+
In this example, the workflow `integration_tests` is not triggered unless it is explicitly invoked when the pipeline is triggered with the following in the `POST` body:
Copy file name to clipboardExpand all lines: jekyll/_cci2/scheduled-pipelines.md
+26-13Lines changed: 26 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,35 @@ contentTags:
8
8
- Cloud
9
9
---
10
10
11
-
## Introduction
12
-
{: #introduction }
13
-
14
11
**Scheduled pipelines are currently available for GitHub and Bitbucket VCS users.** Scheduled pipelines allow you to trigger pipelines periodically based on a schedule. Scheduled pipelines retain all the features of pipelines:
15
12
16
-
- Control the actor associated with the pipeline, which can enable the use of [restricted contexts](/docs/contexts/#project-restrictions)
17
-
- Use [dynamic config](/docs/dynamic-config) via setup workflows
18
-
- Modify the schedule without having to edit `.circleci/config.yml`
19
-
- Take advantage of [auto-cancelling](/docs/skip-build/#auto-cancelling)
20
-
- Specify [pipeline parameters](/docs/pipeline-variables/#pipeline-parameters-in-configuration) associated with a schedule
21
-
- Manage common schedules, for example, across workflows
13
+
- Control the actor (yourself, or the scheduling system) associated with the pipeline, which can enable the use of [restricted contexts](/docs/contexts/#project-restrictions).
14
+
- Use [dynamic config](/docs/dynamic-config) via setup workflows.
15
+
- Modify the schedule without having to edit `.circleci/config.yml`.
16
+
- Take advantage of [auto-cancelling](/docs/skip-build/#auto-cancelling).
17
+
- Specify [pipeline parameters](/docs/pipeline-variables/#pipeline-parameters-in-configuration) associated with a schedule.
18
+
- Manage common schedules, for example, across workflows.
22
19
23
20
Scheduled pipelines are configured through the API, or through the project settings in the CircleCI web app.
24
21
25
22
A scheduled pipeline can only be configured for one branch. If you need to schedule for two branches, you would need to set up two schedules.
26
23
{: class="alert alert-info"}
27
24
25
+
## Introduction
26
+
{: #introduction }
27
+
28
+
Scheduled pipelines allow you to trigger pipelines periodically based on a schedule, from either the CircleCI web app or API. Schedules can range from daily, weekly, monthly, or on a very specific timetable. To set up basic scheduled pipelines, you do not need any extra configuration in your `.circleci/config.yml` file, however, more advanced usage of the feature will require extra `.circleci/config.yml` configuration (for example, workflow filtering, or using parameters).
29
+
30
+
Pipeline parameters are typed pipeline variables in the form of a string, integer, or boolean. Adding a parameter to a scheduled pipeline can be done in the web app in the triggers form while setting up a schedule. Any parameters set up in this manner must be added to your configuration file using the `parameters` key.
31
+
32
+
Scheduled pipelines are set to run by an "actor", either the CircleCI scheduling system, or a specific user (for example, yourself). The scheduling actor is important to consider if making use of restricted contexts in workflows. If the user (actor) running the workflow does not have access to the context, the workflow will fail with the `Unauthorized` status.
33
+
34
+
You can find a basic how-to guide on the [Set a nightly scheduled pipeline](/docs/set-a-nightly-scheduled-pipeline) page, and more advanced examples on the [Schedule pipelines with multiple workflows](/docs/schedule-pipelines-with-multiple-workflows) pages.
35
+
28
36
## Get started with scheduled pipelines
29
37
{: #get-started-with-scheduled-pipelines }
30
38
31
-
To get started with scheduled pipelines, you have the option of using the API, or using the CircleCI web app. Both methods are described below. If you have existing workflows you need to migrate to scheduled pipelines, use the [Scheduled pipelines migration](/docs/migrate-scheduled-workflows-to-scheduled-pipelines) guide.
39
+
To get started with scheduled pipelines, you have the option of using the API, or using the CircleCI web app. Both methods are described below.
32
40
33
41
### Use project settings in the web app
34
42
{: #use-project-settings }
@@ -38,7 +46,7 @@ To get started with scheduled pipelines, you have the option of using the API, o
38
46
3. To create a new schedule, click **Add Trigger**.
39
47
4. Define the new schedule by filling out the form, then click **Save Trigger**.
40
48
41
-
The form also provides the option of adding [pipeline parameters](/docs/pipeline-variables/), which are typed pipeline variables declared at the top level of a configuration.
49
+
The form also provides the option of adding [pipeline parameters](/docs/pipeline-variables/), which are typed pipeline variables that you declare at the top level of a configuration.
42
50
43
51
If you would like to manage common schedules for multiple workflows, you will need to manually set this in your `.circleci/config.yml` file. See the [Schedule pipelines with multiple workflows](/docs/schedule-pipelines-with-multiple-workflows) page for examples.
44
52
@@ -72,6 +80,11 @@ curl --location --request POST "https://circleci.com/api/v2/project/<project-slu
72
80
73
81
For additional information, refer to the **Schedule** section under the [API v2 docs](https://circleci.com/docs/api/v2).
74
82
83
+
## Migrate scheduled workflows to scheduled pipelines
If you have existing scheduled workflows you need to migrate to scheduled pipelines, use the [Scheduled pipelines migration](/docs/migrate-scheduled-workflows-to-scheduled-pipelines) guide.
87
+
75
88
## Scheduled pipelines video tutorial
76
89
{: #scheduled-pipelines-video-tutorial }
77
90
@@ -107,14 +120,14 @@ curl --location --request GET "https://circleci.com/api/v2/project/<project-slug
107
120
--header "circle-token: <PERSONAL_API_KEY>"
108
121
```
109
122
110
-
For GitHub and Bitbucket users: `project-slug` takes the form of `vcs-type/org-name/repo-name`, e.g.`gh/CircleCI-Public/api-preview-docs`.
123
+
For GitHub and Bitbucket users: `project-slug` takes the form of `vcs-type/org-name/repo-name`, for example,`gh/CircleCI-Public/api-preview-docs`.
111
124
112
125
---
113
126
114
127
**Q:** Why is my scheduled pipeline not running?
115
128
116
129
**A:** There could be a few possible reasons:
117
-
* Is the actor who is set for the scheduled pipelines still part of the organization?
130
+
* Is the assigned actor who is set for the scheduled pipelines still part of the organization (you can find this setting is under **Attribution** in the **Triggers** section of the web app)?
118
131
* Is the branch set for the schedule deleted?
119
132
* Is your GitHub organization using SAML protection? SAML tokens expire often, which can cause requests to GitHub to fail.
0 commit comments