Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44143

ECR plugin: no basic auth credentials

XMLWordPrintable

      I'm not able to push Docker images to Amazon ECR with Jenkins Pipeline, I always get 
      no basic auth credentials

      I've added AWS credentials named `aws-jenkins` to Jenkins (tested locally and successfully pushed to AWS ECR)

      Jenkinsfile:

      stage("Docker") {
        dir(path) {
          docker.build("my-image:latest")
        }
        docker.withRegistry("https://<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com", "ecr:eu-central-1:aws-jenkins") {
          // debug
          sh "cat /root/.dockercfg" 
          docker.image("my-image:latest").push()
        }
      }

       

      Logs:

      [Pipeline] withDockerRegistry
      Wrote authentication to /root/.dockercfg
      [Pipeline] {
      [Pipeline] sh
      [docker-emotion-compilers] Running shell script
      + cat /root/.dockercfg
      {"https://<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com": {
      "auth": "[...]",
      "email": "nobody@example.com"
      }}[Pipeline] sh
      [docker-emotion-compilers] Running shell script
      + docker tag --force=true my-image:latest <my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image:latest
      Warning: '--force' is deprecated, it will be removed soon. See usage.
      [Pipeline] sh
      [docker-emotion-compilers] Running shell script
      + docker push <my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image:latest
      The push refers to a repository [<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com/my-image]
      e30bf54e0f87: Preparing
      b9f2c30c0d28: Preparing
      5defc95691fd: Preparing
      295d6a056bfd: Preparing
      no basic auth credentials
      [Pipeline] }
      [Pipeline] // withDockerRegistry

       

      I also tried with other AWS credentials and I always get no basic auth credentials error  

        1. ecr.png
          ecr.png
          48 kB
        2. ecr2.log
          20 kB

            ifernandezcalvo Ivan Fernandez Calvo
            cthiebault Cedric Thiebault
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: