3

Inside of my GitLab CI file I have a file which is copied from the "Publish npm packages instruction",

before_script:
  - |
    {
      echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/"
      echo "${CI_API_V4_URL#https?}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=\${CI_JOB_TOKEN}"
    } | tee --append .npmrc

When I try to run this in Alpine Linux I'm getting.

$ { # collapsed multi-line command
tee: unrecognized option: append
BusyBox v1.31.1 () multi-call binary.
Usage: tee [-ai] [FILE]...
Copy stdin to each FILE, and also to stdout
    -a  Append to the given FILEs, don't overwrite
    -i  Ignore interrupt signals (SIGINT)
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

3

The reason is simple, there are two implementations of tee,

  • Busybox, which Alpine uses, has tee but it doesn't provide an --append. It does provide an -a option (short for append) which is defined as "append to the given FILEs, do not overwrite"
  • GNU CoreUtils provides a copy of tee too it has --append which you're making use of here. It's also defined as "append to the given FILEs, do not overwrite". But as a shorthand, GNU Tee also provides the alias is -a.

So in short, if you want something to be compatible with Alpine and BusyBox as well as distros that ship GNU Tee then use -a (supported in both) instead of --append (supported only in GNU Tee).

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468