sed -i "s|{{PLACEHOLDER}}|${KEY_B64}|g" <path>
The command above is executed in a Gitlab CI runner and throws the following:
sed: unmatched '|'
I have double-checked the KEY_B64 environment variable, it is set and looks valid. This variable is a base-64 encoded JWT token (Kubernetes secrets expect to be base-64 encoded.
What is really strange though is that this command works fine if I run it locally (Ubuntu 22.04) and replace the env variable with the output from echo -n <JWT_TOKEN> | base64
.
Based on the error message, it seems that the env value might contain the delimiter, but changing it to anything else doesn't solve the problem. On top of that, the encoded value for sure doesn't include such symbols.
What could be the cause of the issue?
Updates:
Running sed --version
outputs:
$ sed --version
This is not GNU sed version 4.0
Looking with the set -x
option on, I can see that the encoded string includes newlines (outputted the variable in the pipeline logs).
- Using
printf %s $VAR
did not solve the issue - Surprisingly,
base64
doesn't support-w0