conan-io / conan-package-tools

Conan Package Tools. Helps with massive package creation and CI integration (Travis CI, Appveyor...)
MIT License
166 stars 71 forks source link

Is there a way to use already-stored credentials for upload? #209

Closed datalogics-kam closed 6 years ago

datalogics-kam commented 6 years ago

This project is very handy for building all the combinations of settings and options. Thanks!

Right now, I'm doing builds manually inside my company.

Is there a way to do uploading without supplying a password, presuming that the remote was already added with conan remote add and the password has been stored with conan user -p "" -r remote user?

lasote commented 6 years ago

It depends, if you are building without docker, yes, it should use the local cache, but otherwise you need to use the CONAN_LOGIN_USERNAME and CONAN_PASSWORD variables: https://docs.conan.io/en/latest/reference/env_vars.html#conan-login-username-conan-login-username-remote-name

datalogics-kam commented 6 years ago

Thanks for the reply!

I've been trying that out, and here's what I'm getting. I'm not using Docker, just running from the command line.

This is the code that's running the packager:

@task
def package(ctx, username='datalogics', channel='stable'):
    """Create all the builds of this project."""
    os.environ["CONAN_PIP_USE_SUDO"] = 'False'
    builder = ConanMultiPackager(username=username,
                                 login_username=getpass.getuser(),
                                 channel=channel,
                                 args=[],
                                 build_policy="missing",
                                 archs=["x86_64"],
                                 build_types=['Release'],
                                 apple_clang_versions=['9.1'],
                                 visual_versions=[12],
                                 gcc_versions=["7"],
                                 upload=(remotes[UPLOAD_REMOTE], True, UPLOAD_REMOTE))
    builder.add_common_builds()
    base_profile_name=None
    if sys.platform == 'linux':
        base_profile_name="gcc7"
    builder.run(base_profile_name=base_profile_name)

...and I have a user set up and access to the server with the password sent and a token available.

Current 'bincrafters' user: None (anonymous)
Current 'conan-center' user: None (anonymous)
Current 'conan-local' user: kam

...but the builds end up with this message:

 >> Upload skipped, credentials for remote 'conan-local' not available

Last night, I started tinkering with the credentials_ready() and login() functions in auth.py to detect if Conan has a token for the given user already, and if so, credentials are ready, and a call to authenticate() is unnecessary.

Any suggestions are quite welcome. Am I missing something important?

Thanks!

lasote commented 6 years ago

You are right, I'm not checking if the user is already logged in. Let me check if I can do anything.

lasote commented 6 years ago

Hi, I slightly changed the skip_check_credentials/CONAN_SKIP_CHECK_CREDENTIALS arguments so, when activated, if you do not provide username or password it will try to use the already stored credentials. It is maybe interesting for you to also activate the CONAN_NON_INTERACTIVE environment variable to make sure that the password or login is not prompted. Please, let me know if it helps.

datalogics-kam commented 6 years ago

Works for me! Thanks! I'm going to call this resolved. 👍

In case it's interesting later on, I tinkered yesterday with directly testing to see if Conan had credentials stored. The work is in this commit of my use-cached-auth branch.

I like your fix better, since I ended up having to mess with private variables in Conan more than I felt comfortable with. But the idea will be hanging out in my fork.

lasote commented 6 years ago

Thanks for sharing your commit. I've been analyzing it and the main problem is that I would like to avoid any other import from conan than the conan_api.py (future stable python api), but currently, it doesn't support what we need (as you saw). Actually, we recently opened an issue for that: https://github.com/conan-io/conan/issues/2907 I hope to improve that for 1.5 and then being able to improve the conan package tools.