Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand docs around the deprecation of former secret syntax #4561

Merged
merged 8 commits into from
Dec 14, 2024
29 changes: 28 additions & 1 deletion docs/versioned_docs/version-2.8/20-usage/40-secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Woodpecker provides three different levels to add secrets to your pipeline. The

### Use secrets in commands

:::warning
The use of secrets is deprecated as of version 2.8 and planned to be removed with version 3.
Instead, you can use the *secrets in settings and environment* approach outlined below.
You can already migrate to this strategy with version 2.8.
:::

Secrets are exposed to your pipeline steps and plugins as uppercase environment variables and can therefore be referenced in the commands section of your pipeline,
once their usage is declared in the `secrets` section:

Expand All @@ -32,7 +38,28 @@ The case of the environment variables is not changed, but secret matching is don

You can set an setting or environment value from secrets using the `from_secret` syntax.

In this example, the secret named `secret_token` would be passed to the setting named `token`,which will be available in the plugin as environment variable named `PLUGIN_TOKEN` (See [plugins](./51-plugins/20-creating-plugins.md#settings) for details), and to the environment variable `TOKEN_ENV`.
The example below passes a secret called `token` as an environment variable that will be called `ENV_TOKEN`:
gedankenstuecke marked this conversation as resolved.
Show resolved Hide resolved

```diff
steps:
- name: docker
image: my-plugin
gedankenstuecke marked this conversation as resolved.
Show resolved Hide resolved
+ environment:
+ TOKEN_ENV:
+ from_secret: secret_token
```

You can use the same syntax to pass secrets to settings: For example, you can pass a secret named `secret_token` to the settings (here called `token`), which will then be available in the plugin as environment variable named `PLUGIN_TOKEN` (See [plugins](./51-plugins/20-creating-plugins.md#settings) for details).
gedankenstuecke marked this conversation as resolved.
Show resolved Hide resolved

```diff
steps:
- name: docker
gedankenstuecke marked this conversation as resolved.
Show resolved Hide resolved
image: my-plugin
+ settings:
+ token:
+ from_secret: secret_token
```
You can also combine the two, e.g.
gedankenstuecke marked this conversation as resolved.
Show resolved Hide resolved

```diff
steps:
Expand Down