drone / proposal

Drone Project Design Documents
13 stars 4 forks source link

Allow use of environment variables in plugin settings #30

Open WillGibson opened 2 years ago

WillGibson commented 2 years ago

Currently we can use the built in Drone environment variables in plugin settings, e.g...

steps:
  - name: some-step
    image: some-plugin-docker-image
    settings:
      some_setting: ${DRONE_TAG}

...but not other environment variables, e.g...

environment:
  SOME_ENVIRONMENT_VARIABLE: 7.1.0

steps 
  - name: some-step
    image: some-plugin-docker-image
    settings:
      some_setting: ${SOME_ENVIRONMENT_VARIABLE}

It would be very useful if we could use other environment variables too.

bradrydzewski commented 2 years ago

Hi Will, unfortunately this is not possible because environment variable substitution happens before the YAML is parsed. This creates a chicken and egg problem. If the goal is to keep your yaml DRY, have you considered using YAML anchors? This is a feature native to YAML that allows you to define and use variables. https://medium.com/@kinghuang/docker-compose-anchors-aliases-extensions-a1e4105d70bd