ci: Don't fail on unbound variable in .gitlab/ci/frontend.gitlab-ci.yml
requested to merge 407588-rspec-all-frontend_fixtures-as-if-foss-sometimes-fails-with-ci_node_index-unbound-variable into master
What does this MR do and why?
Unbound variables raise an error even if the call is [[ -n "${UNBOUND_VARIABLE}" ]]
. Changing this to [[ -n "${UNBOUND_VARIABLE:-}" ]]
solves the problem (tested locally).
How to set up and validate locally
You can use the following script to test this locally. The following will raise a test.sh: line 5: CI_NODE_INDEX: unbound variable
error:
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${CI_NODE_INDEX}" ]] && [[ "${CI_NODE_INDEX}" -ne 1 ]]; then
echo "INFO: Removing 'tmp/tests/frontend' as we're on node ${CI_NODE_INDEX}.";
else
echo "\${CI_NODE_INDEX} isn't set."
fi
While the following would just print ${CI_NODE_INDEX} isn't set.
:
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${CI_NODE_INDEX:-}" ]] && [[ "${CI_NODE_INDEX}" -ne 1 ]]; then
echo "INFO: Removing 'tmp/tests/frontend' as we're on node ${CI_NODE_INDEX}.";
else
echo "\${CI_NODE_INDEX} isn't set."
fi
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #407588 (closed)
Edited by Rémy Coutable