jfrog-cli icon indicating copy to clipboard operation
jfrog-cli copied to clipboard

Login non-interactive

Open Breee opened this issue 8 months ago • 4 comments

Greetings,

I tried the following:

CI=true
jf config add artifactory-live --user=${USERNAME} --url=https://<REDACTED< --interactive=false
jf config use artifactory-live
jf login

the jf login command prompts me to select a server for web login:

Use the arrow keys to navigate: ↓ ↑ → ←
Select whether to create a new server configuration or to web login to an existing one:
  🐸 [New Server]
     artifactory-live

Can i somehow avoid the prompt and directly open the browser web-login ?

Breee avatar Apr 09 '25 07:04 Breee

Hey @Breee,

Just to clarify — jfrog web login isn’t intended for use in CI environments, as it requires an interactive browser flow.

It looks like you're setting a config and then calling web login — could you share a bit more about your use case? What are you trying to achieve with this setup?

We’d love to better understand the need so we can help guide you to the best approach.

EyalDelarea avatar Apr 09 '25 10:04 EyalDelarea

I know that it is not for CI, I just thought the flag would cut interactive stuff. Basically automatically setting up developer notebooks using as less interaction as possible. (Login to artifactory, automatically create a token to setup several things) I want to eleminate the possibility that someone selects "New Server" when prompted, but directly uses the config that I want to open a browser window and basically only has to enter the code provided by the CLI in the browser.

Breee avatar Apr 09 '25 10:04 Breee

I see — thanks for the clarification.

What you described would only work smoothly if users are already signed in to the platform, since the browser-based flow depends on that session.

If you're aiming for a non-interactive setup (e.g., for developer notebooks), using a username/password or an access token might be more suitable.

And yes, you're right — currently, the jf login command doesn’t accept any flags to modify its behavior.

We could consider adding a flag to the command that accepts a predefined server ID to avoid the interactive server selection step. Feel free to open a feature request — we’ll definitely take it into consideration.

Do you think that would solve what you're trying to achieve?

EyalDelarea avatar Apr 09 '25 11:04 EyalDelarea

yeah, something like jf login --server-id <server> would be handy to mitigate user errors

Probably needs some changes in https://github.com/jfrog/jfrog-cli-core/blob/4d330e689a8bb400e955cf8a27f088d51accd1d2/general/login/login.go#L20

and https://github.com/jfrog/jfrog-cli/blob/59ffcf80a199285dc9dac8feaac8be7d5f82bf1f/general/login/cli.go#L13

I guess it would be possible to just directly call existingServerLogin(serverId string) if a --server-id is passed to the command or so

Breee avatar Apr 09 '25 12:04 Breee

Hi @Bree,

Thank you for pinpointing the relevant code, the best way forward is to open a formal feature request. This ensures our RND teams can track, prioritize, and implement the change. To make the request as effective as possible, I suggest creating a new issue with type Feature request on GitHub.

venkatanrv avatar Sep 22 '25 05:09 venkatanrv