How to use Forge CLI in a CI environment?

I can confirm @XavierCaron’s assessment, though there are some gotchas that are easy to run into, here’s our current recipe:

  1. do not depend on @forge/cli via package.json (we had it as a dev dependency, which worked up to 1.5.0 and somehow broke in 1.6.0)
  2. ensure to run npm install again before committing package-lock.json after removing any @forge/cli dependency as per 1), otherwise keytar remains configured based on your local interactive environment
  3. instead, install @forge/cli via a separate step in your build environment to ensure it is configured w/o the interactive features (of course, you can optimize build times via a custom build image with the @forge/cli preinstalled) - the mentioned warnings can be ignored, or better yet avoided by ignoring the optional keytar dependency (thanks @remie):
    • npm 6.x: npm install @forge/cli@2.0.1 --no-optional
    • npm 7.x: npm install @forge/cli@2.0.1 --omit optional
  4. ensure to add the --non-interactive flag to applicable commands like forge login and forge install
7 Likes