Our org upgraded from the very legacy drone-agent to drone-runner-docker 1.8 and found that the new runner is unable to set empty env vars in the environment block (only recourse is to use unset or export in commands before execution). This seems unintended since setting
environment:
foo:
reads to be very explicitly setting an existing environment variable in the docker image to be empty upon execution. I also tested with drone-runner-kube 1.0.0-rc3 and it setting empty env vars does work with ‘’ or “” (but not null). Is there a reason why this functionality doesn’t exist for drone-runner-docker / could that be added?
Below is a sample pipeline to reproduce using docker and kubernetes runners.
---
kind: pipeline
type: docker
name: docker
steps:
# outputs 20.10.14
- name: test-empty-string-1
image: docker
pull: if-not-exists
commands:
- echo $DOCKER_VERSION
# outputs 20.10.14
- name: test-empty-string-2
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: null
commands:
- echo $DOCKER_VERSION
# outputs 20.10.14
- name: test-empty-string-3
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: ""
commands:
- echo $DOCKER_VERSION
# outputs asdf
- name: test-empty-string-4
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: asdf
commands:
- echo $DOCKER_VERSION
# outputs 20.10.14
- name: test-empty-string-5
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: ''
commands:
- echo $DOCKER_VERSION
---
kind: pipeline
type: kubernetes
name: kubernetes
steps:
# outputs 20.10.14
- name: test-empty-string-1
image: docker
pull: if-not-exists
commands:
- echo $DOCKER_VERSION
# outputs 20.10.14
- name: test-empty-string-2
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: null
commands:
- echo $DOCKER_VERSION
# outputs empty string
- name: test-empty-string-3
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: ""
commands:
- echo $DOCKER_VERSION
# outputs asdf
- name: test-empty-string-4
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: asdf
commands:
- echo $DOCKER_VERSION
# outputs empty string
- name: test-empty-string-5
image: docker
pull: if-not-exists
environment:
DOCKER_VERSION: ''
commands:
- echo $DOCKER_VERSION