Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting auth credentials from command line or environment variable #693

Closed
victornoel opened this issue Jul 23, 2018 · 11 comments
Closed

Setting auth credentials from command line or environment variable #693

victornoel opened this issue Jul 23, 2018 · 11 comments
Assignees
Milestone

Comments

@victornoel
Copy link

In the case jib-maven-plugin is used in a CI environment, it can be useful to pass the authentication credentials directly via the command line or via environment variable.

For example with Gitlab CI, it is the case that CI jobs have environment variables with temporary tokens to push images to the Gitlab Registry.

Currently, it seems to me that the only way to take advantage of these is either via docker login (which means I need docker installed now) or via some hack by generating a custom settings.xml.

It would be great either to have jib-maven-plugin accept credentials via command line or to document what is the preferred way to achieve the requirement.

@chanseokoh
Copy link
Member

I guess this is similar to #116.

Just FYI, copying a working .docker/config into your CI env will also work. Jib doesn't use docker but just reads the file to get credentials. However, I think that is no different from generating a custom settings.xml, so it doesn't help in your case.

@victornoel
Copy link
Author

Just FYI, copying a working .docker/config into your CI env will also work. Jib doesn't use docker but just reads the file to get credentials.

That's what I had understood, maybe as a workaround there are "simpler" ways to generate the content of this file without using docker… but I suppose the information is not there in its raw form.

@briandealwis
Copy link
Member

briandealwis commented Jul 23, 2018

Could you write a simple docker credential helper script that returns the appropriate environment values? You'd configure that helper with your <to><credHelper> / to.credHelper.

@victornoel
Copy link
Author

@briandealwis yes, that makes total sense, thanks for the idea!

@coollog
Copy link
Contributor

coollog commented Jul 23, 2018

We could also consider adding auth to the image configurations for jib-maven-plugin as well (like we have in jib-gradle-plugin), so people could do:

<configuration>
    <to>
        <image>imagename</image>
        <auth>
            <username>${env.REGISTRY_USERNAME}</username>
            <password>${env.REGISTRY_PASSWORD}</password>
        </auth>
    </to>
</configuration>

and be able to use REGISTRY_USERNAME and REGISTRY_PASSWORD environment variables as the credentials.

@victornoel
Copy link
Author

@coollog I had something like that in mind when I opened the issue yes. Also there should be an expression (in maven lingo) associated to each of those so that one can pass it via -Djib.to.auth.username=XXX (or something like that) too.

@victornoel
Copy link
Author

Thanks @TadCordle :)

@TadCordle
Copy link
Contributor

No problem! Will be available when 0.9.8 releases.

@coollog
Copy link
Contributor

coollog commented Aug 1, 2018

@victornoel version 0.9.8 is released with these features :)

@victornoel
Copy link
Author

@coollog @TadCordle thanks, it works well, I just tested it.

For the record, the README wasn't updated with the new options.

@TadCordle
Copy link
Contributor

Just updated it. Thanks again for your suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants