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

Commitef98758

Browse files
upd /meta/env_vars_to_export in plugins (#353)
1 parent9b43a3a commitef98758

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

‎_docs/codefresh-yaml/steps.md‎

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,23 +951,75 @@ This was a trivial example, but it clearly demonstrates how a custom step commun
951951

952952
###Exporting parameters manually inside a plugin
953953

954-
Normally in a pipeline you can either use the[cf_export]({{site.baseurl}}/docs/codefresh-yaml/variables/#using-cf_export-command) command or write directly to the[/codefresh/volume/env_vars_to_export]({{site.baseurl}}/docs/codefresh-yaml/variables/#directly-writing-to-the-file) file.
954+
Normally, in a pipeline you can either use the[cf_export]({{site.baseurl}}/docs/codefresh-yaml/variables/#using-cf_export-command) command or write directly to the[/codefresh/volume/env_vars_to_export]({{site.baseurl}}/docs/codefresh-yaml/variables/#directly-writing-to-the-file) file.
955955

956-
However inside a plugin you can also use the`/meta/env_vars_to_export` file that has the same semantics, but is used for exporting variables in the same scope as the plugin only.
956+
However, inside a plugin you can also use the`/meta/env_vars_to_export` file that has the same semantics, but is used for exporting variables in the same scope as the plugin only.
957957

958+
The rules for using`/meta/env_vars_to_export` are:
959+
- When the step-type (plugin) does not define the`return` schema, all the output variables from substeps will be projected and exported as the root step (they may override each other).
960+
- When`return` schema is defined, only the variables that matched the definition will be exported as root step.
961+
962+
`plugin.yaml`
958963
{% highlight yaml %}
959964
{% raw %}
965+
version: '1.0'
966+
kind: step-type
967+
metadata:
968+
name: <account_name>/my-step
969+
...
970+
spec:
971+
arguments: |-
972+
{
973+
...
974+
}
975+
returns: |-
976+
{
977+
"definitions": {},
978+
"$schema": "http://json-schema.org/draft-07/schema#",
979+
"type": "object",
980+
"additionalProperties": true,
981+
"patterns":[],
982+
"required":[
983+
"ROOT_VAR"
984+
]
985+
,
986+
"properties": {
987+
"ROOT_VAR": {
988+
"type": "string",
989+
"description": "an example variable"
990+
}
991+
}
992+
}
960993
steps:
961994
export_my_variable:
962995
title: "Exporting custom variable"
963996
image: alpine
964997
commands:
965-
- echo MY_PLUGIN_VAR=SAMPLE_VALUE >> /meta/env_vars_to_export
998+
- echo PLUGIN_VAR=Alice >> /meta/env_vars_to_export
999+
- echo ROOT_VAR=Bob >> /meta/env_vars_to_export
9661000
read_my_variable:
9671001
title: "Reading custom variable"
9681002
image: alpine
9691003
commands:
970-
- echo $MY_PLUGIN_VAR
1004+
- source /meta/env_vars_to_export
1005+
- echo $PLUGIN_VAR #Alice
1006+
- echo $ROOT_VAR #Bob
1007+
{% endraw %}
1008+
{% endhighlight %}
1009+
1010+
1011+
`codefresh.yaml`
1012+
{% highlight yaml %}
1013+
{% raw %}
1014+
version: '1.0'
1015+
steps:
1016+
plugin:
1017+
type: <account_name>/my-step
1018+
echo:
1019+
image: alpine
1020+
commands:
1021+
- echo $PLUGIN_VAR #empty
1022+
- echo $ROOT_VAR #Bob
9711023
{% endraw %}
9721024
{% endhighlight %}
9731025

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp