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
{{ message }}
Repository navigation
Commit bd04826
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/build/variables/index.md
+55-12Lines changed: 55 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ tags:
4
4
- KnowledgeGraph
5
5
- Variables
6
6
---
7
-
# Project and Global Build Variables
7
+
# Build Variables
8
8
9
9
## Introduction
10
10
@@ -147,29 +147,64 @@ They are referenced with the `execution.` prefix, for example `{{execution.myVar
147
147
148
148
Tasks (including workflows) have an **Execution variables** widget in its configuration view, managed in the same way as project variables:
149
149
click on :eccenca-item-add-artefact: to add a variable and provide a name, value and description in the same dialog used for project variables.
150
-
When an execution is started, these variables provide the default values of the execution scope.
151
-
For a workflow run, the defaults come from the **workflow itself** — the execution variables of the operators and datasets inside the workflow are not used during a workflow run; they apply when such a task is executed directly.
150
+
The widget is offered on every task.
151
+
Its values take effect when that task is the one being executed, where they provide the defaults of the execution scope.
152
+
A task that only runs as part of a workflow receives its values from the enclosing workflow, so its own widget stays unused.
153
+
154
+
### Where Execution Variables Resolve
155
+
156
+
Project and global variables are resolved when a task is saved, which is why they can be used in any parameter field that offers the **{#}** toggle.
157
+
An execution variable only has a value while a run is in progress.
158
+
It therefore takes effect in parameters that are evaluated once per execution, such as the template of the **Evaluate template** workflow operator and of the **Evaluate template** transformer.
159
+
A reference such as `{{execution.myVariable}}` resolves there to the value of the current run.
160
+
161
+
A template in an ordinary parameter field behaves differently.
162
+
It is resolved when the task is loaded, and the result is kept until the task is loaded again.
163
+
An execution variable referenced in such a field does not change the result from run to run and is not a way to parameterize a plugin per execution.
164
+
To give a plugin parameter a value that differs per run, use the [config port](../workflows/index.md#workflow-reconfiguration) of the operator.
165
+
166
+
### Determining the Variables of a Run
167
+
168
+
The set of execution variables of a single run is built in three steps:
169
+
170
+
1. The defaults come from the task that is executed.
171
+
For a workflow run these are the execution variables of the workflow itself.
172
+
The execution variables of the operators, datasets and sub-workflows inside the workflow are not read; they apply when such a task is executed directly.
173
+
2. Values given at the start of the run replace defaults of the same name.
174
+
A value given at the start of a run also defines a variable that is not declared on any task.
175
+
3.**Set execution variable** operators create or replace entries while the run proceeds.
176
+
177
+
The resulting set is used by every task of the run, including sub-workflows.
178
+
Two consequences follow from this:
179
+
180
+
- A variable that a task or a sub-workflow inside a workflow references must be defined on the executed workflow itself, or be given at the start of the run.
181
+
There is no fallback to the definition on the inner task.
182
+
- Variable names form a single flat set.
183
+
The same name used by two tasks always receives the same value; different values for the same name in different tasks are not possible.
152
184
153
185
`{{execution.<name>}}` resolves only from the execution scope — there is no fallback to other scopes.
154
186
If `<name>` has not been defined as a default, provided or set for the run, the reference cannot be resolved and the execution fails with an error.
155
187
To base a default on a project or global variable, give the execution variable a *template* (e.g. `{{project.baseUrl}}/api`); it is resolved when the variable is saved, and the resulting value is used for each run.
156
188
157
-
!!! note
158
-
159
-
Execution variables are resolved in templates that are evaluated **during execution**, for example the template of the template operator.
160
-
161
189
!!! note
162
190
163
191
The execution variables of a task are stored together with the task (their default values, not any run-specific overrides).
164
192
When the task or its project is exported, they are exported as well.
165
193
The values of a running execution are never persisted and are not shared between runs.
166
194
167
-
Besides the defaults defined in the widget, there are two further ways to supply execution variables for a run:
195
+
### Passing Execution Variables When Starting a Workflow
196
+
197
+
When a workflow execution is triggered via the REST API, execution variables are provided in one of two ways.
198
+
199
+
The first is a query parameter per variable, with the reserved prefix `variable-`:
168
200
169
-
### Passing execution variables when starting a workflow
201
+
```text
202
+
?variable-testVar=World
203
+
```
204
+
205
+
This form works for every endpoint, request content type and request method, including `GET`.
170
206
171
-
When a workflow execution is triggered via the REST API, execution variables can be provided in the JSON request body under the `executionVariables` key as a simple name/value map.
172
-
For example, executing a workflow with a single execution variable `testVar`:
207
+
The second is a name/value map under the `executionVariables` key of a JSON request body:
173
208
174
209
```json
175
210
{
@@ -179,10 +214,18 @@ For example, executing a workflow with a single execution variable `testVar`:
179
214
}
180
215
```
181
216
217
+
Values are strings in both forms.
218
+
The request body form is not available on endpoints that accept a replaceable input dataset, because the body of such a request carries the data for that dataset.
219
+
182
220
Each entry is set in the `execution` scope — overriding a default of the same name defined on the workflow — and can be referenced anywhere in the workflow as `{{execution.<name>}}`.
183
221
For instance, an operator configured with the template `{{value}} {{execution.testVar}}` would resolve `execution.testVar` to `World` for that run.
184
222
185
-
### Setting execution variables during a workflow run
223
+
Querying `GET /api/core/variableTemplate/variables` for a workflow with the `transitive` flag returns every variable that has to be set for a run of that workflow:
224
+
the execution variables of the workflow itself together with those of every task and sub-workflow that may take part in the execution.
225
+
If the same name is defined on several levels, the definition of the enclosing workflow is returned, which is the one that applies during the run.
226
+
These endpoints are described in the [DataIntegration API documentation](../../develop/dataintegration-apis/index.md).
227
+
228
+
### Setting Execution Variables During a Workflow Run
186
229
187
230
Execution variables can also be created or updated while a workflow is running.
188
231
Two operators in the *Variables* category support this:
0 commit comments