Drone-kube-runner has no DRONE_STEP_NUMBER env variable during building

Hi,

I cannot get DRONE_STEP_NUMBER environment variable in the pipeline using drone-kube-runner.
I think this is the same situation like this topic.

As the result of the above topic, new runner-go was applied on the below PR.
DRONE_STEP_NAME was added, however DRONE_STEP_NUMBER was not.

version

  • drone/drone:1.10.1
  • drone/drone-runner-kube:1.0.0-beta.8

pipeline

- name: check-file
  image: golang
  commands:
  - echo $DRONE_STEP_NUMBER
  - echo $DRONE_STEP_NAME

build log

+ echo $DRONE_STEP_NUMBER
+ echo $DRONE_STEP_NAME
check-file

This is a known issue in Kubernetes runner. See https://docs.drone.io/runner/kubernetes/overview/, section “Known Issues / Differences”, the first bullet. You have to read /run/drone/env file in a container and the value of io.drone.build.number will give you the step number.

This is because Kubernetes runner, when executing a pipeline, creates a pod with containers for all defined steps (once a pod starts, no new containers can be added to it). Initially all these containers start with a tiny placeholder image… It does nothing, it just waits. When a step is ready for execution, the runner changes its container image, but can’t change environment variables. Environment variables remain with the same values as when the pod started. So, to work around this Kubernetes restriction, we have read /run/drone/env file to get values that change during pipeline execution.

Thank you for your response.
I could get DRONE_STEP_NUMBER from io.drone.build.number.
Then I completely understood why “Known Issues / Differences” occurs on kubernetes runner.