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

withDockerRegistry fails to login with complex password

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None
    • Jenkins 2.134
      Docker Pipeline 1.17

      Jenkinsfile:

          stage('Deliver') {
            steps {
              withDockerRegistry([credentialsId: 'docker-creds', url: '']) {
                sh "docker push imagename"
              }
            }
          }
      

      Error:

      $ docker login -u username -p ******** https://index.docker.io/v1/
      WARNING! Using --password via the CLI is insecure. Use --password-stdin.
      Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
      

      Workaround:

      Change Docker Hub password from something complex (e.g. "]GT~XMRZwWc6]dUg:NMs") to something very simple (e.g. "insecurepass"). Using a simple password that is very long (e.g. "verylongpasswordhere") works fine too.

      `docker login` using complex password from the CLI works just fine.

          [JENKINS-52761] withDockerRegistry fails to login with complex password

          Johan Maasing added a comment - - edited

          Just ran into the same issue (Jenkins ver. 2.204.1)

          It looks like the plugin does not quote the arguments. In my case the password is actually a JSON file from google.

          So from a bash shell this does not work, it gives the same error message as I see in the jenkins logs from withDockerRegistry

           

          docker login -u _json_key -p $(cat jsonkey.json) https://eu.gcr.io/...

           

           

          However this works in the bash shell:

          docker login -u _json_key -p "$(cat jsonkey.json)" https://eu.gcr.io/...

          Note the usage of quotes ".

          I guess the plugin has similar problems when passing the arguments to the command line.

           

          Johan Maasing added a comment - - edited Just ran into the same issue (Jenkins ver. 2.204.1) It looks like the plugin does not quote the arguments. In my case the password is actually a JSON file from google. So from a bash shell this does not work, it gives the same error message as I see in the jenkins logs from withDockerRegistry   docker login -u _json_key -p $(cat jsonkey.json) https://eu.gcr.io/...     However this works in the bash shell: docker login -u _json_key -p "$(cat jsonkey.json)" https://eu.gcr.io/... Note the usage of quotes ". I guess the plugin has similar problems when passing the arguments to the command line.  

          Jared Biel added a comment - - edited

          In case anyone runs across this, I've opened a PR (https://github.com/jenkinsci/docker-commons-plugin/pull/86) to solve this issue. The artifact from that PR build can be manually installed in Jenkins until it's merged or fixed in some other way (https://ci.jenkins.io/job/Plugins/job/docker-commons-plugin/job/PR-86/1/artifact/org/jenkins-ci/plugins/docker-commons/1.17-rc347.f3e1aa3e5799/docker-commons-1.17-rc347.f3e1aa3e5799.hpi).

          Jared Biel added a comment - - edited In case anyone runs across this, I've opened a PR ( https://github.com/jenkinsci/docker-commons-plugin/pull/86 ) to solve this issue. The artifact from that PR build can be manually installed in Jenkins until it's merged or fixed in some other way ( https://ci.jenkins.io/job/Plugins/job/docker-commons-plugin/job/PR-86/1/artifact/org/jenkins-ci/plugins/docker-commons/1.17-rc347.f3e1aa3e5799/docker-commons-1.17-rc347.f3e1aa3e5799.hpi ).

          Isn't withDockerRegistry from Jenkins "docker-workflow-plugin" plugin?

          Reinhold Füreder added a comment - Isn't withDockerRegistry from Jenkins "docker-workflow-plugin" plugin? See JENKINS-64690

            Unassigned Unassigned
            gtirloni Giovanni Tirloni
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: