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

upd /meta/env_vars_to_export in plugins#353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kostis-codefresh merged 1 commit intomasterfromCR-2077
Dec 8, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions_docs/codefresh-yaml/steps.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -951,23 +951,75 @@ This was a trivial example, but it clearly demonstrates how a custom step commun

### Exporting parameters manually inside a plugin

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.
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.

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.
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.

The rules for using `/meta/env_vars_to_export` are:
- 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).
- When `return` schema is defined, only the variables that matched the definition will be exported as root step.

`plugin.yaml`
{% highlight yaml %}
{% raw %}
version: '1.0'
kind: step-type
metadata:
name: <account_name>/my-step
...
spec:
arguments: |-
{
...
}
returns: |-
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": true,
"patterns": [],
"required": [
"ROOT_VAR"
]
,
"properties": {
"ROOT_VAR": {
"type": "string",
"description": "an example variable"
}
}
}
steps:
export_my_variable:
title: "Exporting custom variable"
image: alpine
commands:
- echo MY_PLUGIN_VAR=SAMPLE_VALUE >> /meta/env_vars_to_export
- echo PLUGIN_VAR=Alice >> /meta/env_vars_to_export
- echo ROOT_VAR=Bob >> /meta/env_vars_to_export
read_my_variable:
title: "Reading custom variable"
image: alpine
commands:
- echo $MY_PLUGIN_VAR
- source /meta/env_vars_to_export
- echo $PLUGIN_VAR #Alice
- echo $ROOT_VAR #Bob
{% endraw %}
{% endhighlight %}


`codefresh.yaml`
{% highlight yaml %}
{% raw %}
version: '1.0'
steps:
plugin:
type: <account_name>/my-step
echo:
image: alpine
commands:
- echo $PLUGIN_VAR #empty
- echo $ROOT_VAR #Bob
{% endraw %}
{% endhighlight %}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp