Snapcraft export-login without prompt username and password

I’d like to export login credential every 3 months , but via CICD pipeline.

currently when run snapcraft export-login exported, it will prompt for username and password, then will generate the credentials file called exported.

later I can easily save this file exported as CICD pipeline secrets. In pipeline tasks, I can easily login with it.

snapcraft login --with exported

So I need parameters in snap-craft export-login with extra options, such as:

--username xxxx
--password xxxx

The command looks like this

# ${username} and ${password} are saved as secure environment variables in CICD pipeline

$ snapcraft export-login --username ${username} --password ${password}  exported

So I can run the command without prompt. Any suggestions to implement it?

so the code ( ) hard code to only get username/password from prompt

    email = ""
    password = ""

    if not config_fd:
        echo.wrapped("Enter your Ubuntu One e-mail address and password.")
            "If you do not have an Ubuntu One account, you can create one "
        email = echo.prompt("Email")
        if os.getenv("SNAPCRAFT_TEST_INPUT"):
            # Integration tests do not work well with hidden input.
            echo.warning("Password will be visible.")
            hide_input = False
            hide_input = True
        password = echo.prompt("Password", hide_input=hide_input)

But why?


_store is part of the cli, it makes sense it would only support what we expose on the CLI.

but if we’d like to run the command with automation way, it becomes a block.

there should be a flexable way to allow clients to login via command line directly. such as

snapcraft export-login --username xxxx --password xxxx exported