How to use Forge CLI in a CI environment?

Hi!

I’ve trying to run Forge CLI in our GitHub workflows but I keep receiving the following message:

Error: Keytar error detected: Cannot autolaunch D-Bus without X11 $DISPLAY
Something went wrong while accessing Secret Service API.

As this is running in the CI, there is no interactive prompt available. This happens both with the login and lint commands (I haven’t tried others yet).

I’ve also tried executing the login:ci command and setting the output token to the env variable FORGE_CI_TOKEN, but the result is the same.

Any ideas?

1 Like

Have you tried the --non-interactive flag already? This is what we use in Bitbucket Pipelines:

forge settings set usage-analytics false
forge login --email $FORGE_EMAIL --token $FORGE_TOKEN --non-interactive

Cheers,
Sven

1 Like

Thanks for you reply Sven.

I already had the usage-analytics setting set to false, but I missed the non-interactive option from the login.

Unfortunately adding it yields the same result (I’ve also added the --verbose flag to get more details):

Run npm install -g @forge/cli
  npm install -g @forge/cli
  forge settings set usage-analytics false
  forge login --email *** --token *** --non-interactive --verbose
  shell: /usr/bin/bash -e {0}
/opt/hostedtoolcache/node/12.21.0/x64/bin/forge -> /opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/out/bin/cli.js

> keytar@5.6.0 install /opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/node_modules/keytar
> prebuild-install || node-gyp rebuild


> @forge/cli@1.3.0 postinstall /opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli
> node -e "process.exitCode = fs.existsSync('./out/bin/postinstall.js')" || node ./out/bin/postinstall.js

+ @forge/cli@1.3.0
added 792 packages from 456 contributors in 11.294s
✔ Successfully set usage-analytics as false.

Log in to your Atlassian account
Press Ctrl+C to cancel.

Logging you in...

  ▶️  GraphQL https://api.atlassian.com/graphql
Query: {me {user {name accountStatus accountId}}}
Variables: {}
  ◀️  GraphQL
Request ID: 71d3774d706a9ccc
Result: {
  "me": {
    "user": {
      "name": "Rodrigo Nogués",
      "accountStatus": "active",
      "accountId": "xxxxx"
    }
  }
}

Error: Keytar error detected: Cannot autolaunch D-Bus without X11 $DISPLAY
Something went wrong while accessing Secret Service API.

Error: Keytar error detected: Cannot autolaunch D-Bus without X11 $DISPLAY
Something went wrong while accessing Secret Service API.
    at KeytarPersonalApiCredentialsStore.wrapKeytarError (/opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/node_modules/@forge/cli-shared/out/auth/personal/token-store-keytar.js:90:15)
    at /opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/node_modules/@forge/cli-shared/out/auth/personal/token-store-keytar.js:67:32
    at async LoginCommand.execute (/opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/node_modules/@forge/cli-shared/out/auth/personal/login.js:15:9)
    at async CommandLineUI.displayProgress (/opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/node_modules/@forge/cli-shared/out/ui/command-line-ui.js:44:28)
    at async loginCommandHandler (/opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/out/command-line/register-authentication-command.js:32:38)
    at async Command.actionProcessor (/opt/hostedtoolcache/node/12.21.0/x64/lib/node_modules/@forge/cli/out/command-line/command.js:74:32)
Error: Process completed with exit code 1.

Regards,
Rodrigo.

1 Like