woodpecker-ci / woodpecker

Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
3.88k stars 345 forks source link

Agents environment variables #3311

Open biolds opened 5 months ago

biolds commented 5 months ago

Hello,

I'm trying to set per agent environment variables but could not find a way to do it. I want to use them to set ip addresses to access external resources that varies by agent. So far, I have tried without success:

Did I miss a way to pass agent specific data to the steps, or a way to identify which worker is running the test ?

Thanks for your effort on this great software!

Suggested solution

Support one of the three way I tried.

Alternative

No response

Additional context

No response

Validations

silverwind commented 4 weeks ago

It's not implemented yet it seems. My proposal from https://github.com/woodpecker-ci/woodpecker/issues/3762 is:

Support a option WOODPECKER_AGENT_ENV_FILE that works like DRONE_RUNNER_ENV_FILE which can be mounted into the agent which would make the environment variables available to all pipelines.

Alternatively, it could possibly done in the agent config ui too.

zc-devs commented 4 weeks ago

it could possibly done in the agent config ui too

Sounds similar to https://github.com/woodpecker-ci/woodpecker/pull/3723, but for/per Agent.


Two approaches can be implemented at the same time:

  1. UI for global, agent, org, repo envs.
  2. Env file: 2.1 Server's env file for global envs, 2.2 Agent's env file for Agent's envs, 2.3 Env file in the repo or special pipeline syntax for repo's envs, 2.4 Seems, organization envs cannot be implemented that way.