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
Add section to reference shared config in YAML (codefresh-io#715)
* Add section to reference shared config in YAML
Added section to reference shared config and made content edits
* Add reference shared config example to api
Moved referencing shared config context as example to pipeline API and added xref in shared config topic
* Update shared-configuration.md
Added reference example to programmatic section with xrefs to CLI context command and full pipeline specifications
* Minor content edits
* Update shared-configuration.md
* Update shared-configuration.md
Fixed link
* Update shared-configuration.md
Use shared configuration contexts in your pipelines by referencing it in the pipeline's YAML. This method is an alternative to importing the shared configuration contexts with the variables to use from the UI.
237
+
238
+
Add the `spec.contexts` field followed by the name or names of the shared configuration context or contexts to use.
239
+
240
+
>**IMPORTANT**:
241
+
Referencing shared configuration contexts with `spec.contexts` only works programmatically via the CLI/API.
242
+
The UI-based YAML options (**inline YAML**, **Use YAML from Repository/URL**) do not support this.
243
+
244
+
245
+
If you have a shared configuration named `test-hello` that includes the variable `test=hello`, you can add `spec.contexts.test-hello` to the pipeline YAML, and then reference this variable in the pipeline as you would any other variable.
246
+
247
+
{% highlight shell %}
248
+
{% raw %}
249
+
version: "1.0"
250
+
kind: pipeline
251
+
metadata:
252
+
name: default/test-shared-config-from-pipe-spec
253
+
spec:
254
+
contexts:
255
+
- test-hello
256
+
steps:
257
+
test:
258
+
image: alpine
259
+
commands:
260
+
- echo ${{test}} # should output "hello"
261
+
{% endraw %}
262
+
{% endhighlight %}
263
+
235
264
## Full pipeline specification
236
265
237
266
If you don't want to create a pipeline from an existing one, you can also create your own YAML from scratch.
You can create four types of shared configuration:
47
+
You can create four types of shared configuration contexts:
38
48
39
49
***Shared Configuration**: for environment variables
40
50
***Shared Secret**: for encrypted environment variables of sensitive data (access tokens, etc.)
@@ -82,6 +92,7 @@ max-width="60%"
82
92
We recommend that you disable access for all values of type *shared secret* and *secret YAML* unless your organization has different needs.
83
93
84
94
95
+
85
96
## Using shared environment variables
86
97
87
98
Each pipeline has a set of environment variables that can be defined in the *Workflow* screen.
@@ -113,12 +124,13 @@ Once you click *Add* the values from the shared configuration will be appended t
113
124
you have in your pipelines. In case of similar values the shared configuration will follow the [precedence rules]({{site.baseurl}}/docs/pipelines/variables/#user-provided-variables).
114
125
115
126
127
+
116
128
## Using shared Helm values
117
129
118
-
To use a shared YAML snippet for Helm values you can install a new Helm chart either from:
130
+
To use a shared YAML snippet for Helm values you can install a new Helm chart either from the:
You can also create/update/delete shared configuration via the [Codefresh CLI](https://codefresh-io.github.io/cli/) or [API]({{site.baseurl}}/docs/integrations/codefresh-api/).
269
+
You can also manipulate shared configurations programmatically via the [Codefresh CLI](https://codefresh-io.github.io/cli/){:target="\_blank"} and the [Codefresh API](https://g.codefresh.io/api/){:target="\_blank"}.
270
+
271
+
For example, you can reference one or more shared configuration contexts directly in the YAML using `spec.contexts` as described below.
272
+
273
+
If you have a shared configuration named `test-hello` that includes the variable `test=hello`, you can add `spec.contexts.test-hello` to the pipeline YAML, and then reference this variable in the pipeline as you would any other variable.
274
+
275
+
{% highlight shell %}
276
+
{% raw %}
277
+
version: "1.0"
278
+
kind: pipeline
279
+
metadata:
280
+
name: default/test-shared-config-from-pipe-spec
281
+
spec:
282
+
contexts:
283
+
- test-hello
284
+
steps:
285
+
test:
286
+
image: alpine
287
+
commands:
288
+
- echo ${{test}} # should output "hello"
289
+
{% endraw %}
290
+
{% endhighlight %}
291
+
292
+
293
+
294
+
For detailed information on how to create/update/delete shared configuration contexts via the CLI, see [Contexts](https://codefresh-io.github.io/cli/contexts/){:target="\_blank"}.
258
295
259
-
See the [context section](https://codefresh-io.github.io/cli/contexts/create-context/) in the CLI documentation.
296
+
For information on all the options available in the _full Codefresh YAML_, see [Full pipeline specifications]({{site.baseurl}}/docs/integrations/codefresh-api/#full-pipeline-specification).
0 commit comments