Skip to content

Use ECR credentials without docker-workflow plugin #172

Open
@cg2v

Description

@cg2v

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions