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

Use ECR credentials without docker-workflow plugin #172

Open
cg2v opened this issue Feb 16, 2024 · 1 comment
Open

Use ECR credentials without docker-workflow plugin #172

cg2v opened this issue Feb 16, 2024 · 1 comment

Comments

@cg2v
Copy link

cg2v commented Feb 16, 2024

What feature do you want to see added?

I would like the credentials returned by credentials('ecr::') to be usable as environment variables with docker login/podman login.

My site uses podman, not docker for builds, and I am not confident that the docker-workflow plugin will function with podman as the backend, so I am not using it. Instead I am invoking podman using sh().

When I try to log in to an ECR registry, like so:

   stages {
        stage('Prep') {
            environment {
               AWS_REGISTRY = credentials('ecr:us-east-1:aws')
            }
            steps {
               sh 'podman login -u $AWS_REGISTRY_USR -p $AWS_REGISTRY_PSW $AWS_REGISTRY_HOST'
            }
       }
   }

the login fails with an invalid token. When I inspect $AWS_REGISTRY_PSW, I discover that it is the entire token returned by GetAuthorizationToken, which means it's a base64 encoded string of Username:Password

Instead, I have to ignore the amazon-ecr plugin and do something like this in my steps:

                withCredentials([aws(credentialsId: 'aws')]) {
                    sh 'aws ecr get-login-password --region us-east-1 | \
                        podman login -u AWS --password-stdin $AWS_REGISTRY_HOST'
                }

Upstream changes

No response

Are you interested in contributing this feature?

No response

@TobiX
Copy link
Contributor

TobiX commented May 15, 2024

I have started using https://github.com/isometry/docker-credential-env, maybe that also works for you?

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

No branches or pull requests

2 participants