Fix $TEST_ENV_NUMBER replacing code to not affect all processes #905
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.
Hi. I was trying to create a small script running some custom tests in parallel where I need the TEST_ENV_NUMBER in an other ENV variable, so I naturally tried to reassing it, something like this:
parallel_test -n 3 --first-is-1 -e 'bash -c "export CI_NODE_TOTAL=3 && export CI_NODE_INDEX=$TEST_ENV_NUMBER && echo $CI_NODE_INDEX / $CI_NODE_TOTAL"'
However, it printed
1 / 3
for all processes instead of1 / 3
,2 / 3
and3 / 3
. Then I found this line that replaces$TEST_ENV_NUMBER
and${TEST_ENV_NUMBER}
with the current number by modifying the originalcmd
array which affects all the other processes as there won't be$TEST_ENV_NUMBER
substring in them anymore.I added one spec that initially failed on the branch and got fixed by my change, I hope I found the right place for it.
Let me know if you need anything else :)
Checklist
master
(if not - rebase it).code introduces user-observable changes.