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

Global environment option to set env variables across all steps #3661

Open
3 tasks done
Andre601 opened this issue Apr 29, 2024 · 0 comments · May be fixed by #3723
Open
3 tasks done

Global environment option to set env variables across all steps #3661

Andre601 opened this issue Apr 29, 2024 · 0 comments · May be fixed by #3723
Labels
enhancement improve existing features pipeline-config related to pipeline config files (.yaml)

Comments

@Andre601
Copy link
Contributor

Clear and concise description of the problem

Right now, there only seems to be a way to define global env variables for the entire CI, rather than a single pipeline itself.
In addition is this from what I understand only something an admin can do, meaning users on a shared instance may not have a way to easily define an environment that is accessible across all steps (See "Alternatives" for the ones I know of and their (mostly) cons).

Suggested solution

A global environment option should be implemented, which allows you to define the environment variables you want to use across all steps.

I'm unsure if this global one should be overridable by a step-level environment setting with the same name.

Example:

when:
  - event: push

environment:
  FOO: BAR # Set a global env here.

steps:
  - name: 'echo'
    image: bash
    commands:
      - echo ${FOO}
  - name: 'echo again'
    image: bash
    environment:
      FOO: NOT_BAR # Should this be possible?
    commands:
      - echo ${FOO}

Alternative

From what I understand and gathered are there these possible alternatives, which all have some downsides to them:

  • Set a secret.
    • - Using a secret for sharing a non-secret value globally seems wrong.
    • - doesn't allow using other env variables to be processed(? Unsure about this one).
    • + It's available across all steps and can also be used in plugin settings.
  • Create a step that saves a value to an envvars file and then later get it.
    • - Depending on the image set may require different commands to set and get.
    • - You can't pull the env in a plugin (unless there is an aproach to run commands before the image execution somehow).
    • - Requires to pull the envvars file on every step to make it available.
    • + Above negative allows only exposing the env to specific steps.

Additional context

No response

Validations

  • Checked that the feature isn't part of the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@Andre601 Andre601 added the feature add new functionality label Apr 29, 2024
@qwerty287 qwerty287 added enhancement improve existing features pipeline-config related to pipeline config files (.yaml) and removed feature add new functionality labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features pipeline-config related to pipeline config files (.yaml)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants