[SOLVED] Newline characters in multiline secret value get replaced with spaces

I’m trying to:

  1. Store SSH private key (which contains newline characters) in a secret
  2. Send it to a build step in an environment variable
  3. Save environment variable into some file
  4. Use this file in a ssh -i some_file command.

After doing that some_file contains spaces instead of newline characters.

I can not find “official” documentation on using multiline secrets. Is it expected (and documented) behaviour?

I solved the issue by add double quotes around env variable in echo statement!

My original execution step script contained:

echo $DRONE_SECRET_VALUE > some_file

After changing it to

echo "$DRONE_SECRET_VALUE" > some_file

there is no more problem with spaces instead of newlines!