-
Notifications
You must be signed in to change notification settings - Fork 312
DEV-510: Fix availability of CI env var on remote executions #4545
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
Conversation
Signed-off-by: Nacho Fuertes <nacho@okteto.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4545 +/- ##
=======================================
Coverage 46.16% 46.16%
=======================================
Files 355 355
Lines 28393 28393
=======================================
Hits 13109 13109
Misses 14173 14173
Partials 1111 1111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was curious and read about this here, in case helps someonelse undertand the issue https://vsupalov.com/docker-arg-env-variable-guide/
@@ -86,7 +86,7 @@ WORKDIR /okteto/src | |||
ENV {{$key}}={{$val}} | |||
{{end}} | |||
{{range $key, $val := .OktetoCommandSpecificEnvVars }} | |||
ARG {{$key}} {{$val}} | |||
ENV {{$key}}={{$val}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARG {{$key}}={{$val}}
also works. The main difference between ARG
and ENV
is that you can change the value of ARG for different builds. Since we autogenerate these dockerfiles, instead of passing ARG values for the same dockerfile, both options are equivalent.
Proposed changes
Fixes DEV-510
Nicklas reported some time ago that the
CI
env var wasn't being propagated correctly to the test execution in remote. I was taking a look at it today as it also affected to env varOKTETO_IS_PREVIEW_ENVIRONMENT
. After some testing, I saw that is related to usingARG
instead ofENV
. I'm not sure why, but using ARG with default value is not making that env var available inremote-run
command. The only way I had to make it available was:ENV
instead ofARG
As there is not final image built, which is the main difference between
ENV
andARG
(the availability of that var in the running container or not), I opted by switching it to useENV
How to validate
CI
andOKTETO_IS_PREVIEW_ENVIRONMENT
.export CI=true
andexport OKTETO_IS_PREVIEW_ENVIRONMENT=true
okteto test unit
with the CLI 3.0, you will see how nothing is printedCLI Quality Reminders 🔧
For both authors and reviewers: