woodpecker-ci / woodpecker

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

Variable expansion everywhere, not only commands: block #2330

Open denisz1 opened 1 year ago

denisz1 commented 1 year ago

Clear and concise description of the problem

Hello!

We can use environment var like:

variables:
  - &env
    - SOMETHING=bar

steps:
  build:
    image: bash
    environment: *env
    commands:
      - foo "$SOMETHING"

But not like this (I use docker plugin only for example):

variables:
  - &env
    - registry_url=ourregistry.com
    - repo_name=therepo

steps:
  docker:
    image: woodpeckerci/plugin-docker-buildx
    environment: *env
    settings:
      registry: ${registry_url}
      username: ${CI_REPO_OWNER}
      password:
        from_secret: secret
      repo: ${registry_url}/${CI_REPO_OWNER}/$repo_name

It can not work for repo: ourregistry.com/${CI_REPO_OWNER}/$repo_name because it not expands those variables registry_url and repo_name and they are blank.

I read the documents. I think this not available now - we can expand env vars in commands: block only. (I am correct?)

We have microservices and so many '.woodpecker.yml' files! Very hard to use. So would be good to have them "DRY" with more variables substitution/expansion.

Suggested solution

Please can we use env vars anywhere in file?

Alternative

No response

Additional context

No response

Validations

OCram85 commented 5 months ago

This could also help hiding sensitive data like proxy credentials for the docker-buildkit plugin