Add DRONE_STEP_NUMBER to environment variables #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've noticed that https://docs.drone.io/pipeline/environment/reference/drone-step-number/ is not being set in the environment variables for pipelines run using this kube runner.
I believe the problem is this:
The pod environment is created in engine.Setup from calls
toPod -> toContainers -> toContainer -> toEnv
. When this happens we don't yet have a StepNumber, we've only set theDRONE_STEP_NAME
.engine.Setup
is called from Execer.Exec, and later in that function in a call toExecer.exec
theDRONE_STEP_NUMBER
is supposed to set by on the step here. At this point the pod spec was already created, so this env var never makes it to the pod.In this PR I've attempted to fix the problem by passing a step number in
Compiler.Compile
where the rest of the environment variables are set. I found that this is how #61 fixed theDRONE_STEP_NAME
env variable.This fix is maybe not ideal because it's assuming the steps are not re-ordered in any way later, but it seems like it may be the only way to fix this problem without a larger change to where the pods specs are created.