Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRONE_STEP_NUMBER to environment variables #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dnephin
Copy link

@dnephin dnephin commented Aug 23, 2024

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 the DRONE_STEP_NAME.

engine.Setup is called from Execer.Exec, and later in that function in a call to Execer.exec the DRONE_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 the DRONE_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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants