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

Docker Pipeline causes build to fails because of use of --force=yes for tagging


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • docker-workflow-plugin
    • None
    • Jenkins 2.32.2
      Docker 1.12.3
      Docker Pipeline Plugin 1.10

      First off, I verify that I have read other tickets relating to similar issues, especially https://issues.jenkins-ci.org/browse/JENKINS-41140. I am convinced this is not a duplicate.

      This Jenkinsfile exits and fails the build as soon as I try to do a Image.push('tag') with error code 125.

      // define name of project
      projectBaseName = 'gradle'
      node {
        def tagVersion= sh(script:"git tag -l --sort=-creatordate | head -n 1", returnStdout: true)
        echo tagVersion
        stage('checkout') {
          checkout scm: [
            $class: 'GitSCM', 
            userRemoteConfigs: [[credentialsId: 'erentodevsSSH', url: 'git@github.com:erento/infra-gradle.git']],
            branches: [[name: "refs/tags/${tagVersion}"]]],
            changelog: false,
            poll: false  
        def myImage
        stage('build image') {
          myImage = docker.build("eu.gcr.io/erento-docker/${projectBaseName}")
        stage('publish image') {
          myImage.push "${tagVersion}"
          myImage.push 'latest'

      Here is the end of the log where the build fails:

      Successfully built 5cd83ad22ca8
      [Pipeline] dockerFingerprintFrom
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (publish image)
      [Pipeline] sh
      [-_Infra_infra-gradle_master-324YNW3MJA4FOWI2NQMEZBAZKMJ727NUFOWZA5FUGORPAAWKKMVA] Running shell script
      + docker tag --force=true eu.gcr.io/erento-docker/gradle eu.gcr.io/erento-docker/gradle:3.3-1
      unknown flag: --force
      See 'docker tag --help'.
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      GitHub has been notified of this commit’s build result
      ERROR: script returned exit code 125
      Finished: FAILURE

      I have verified that switching the order of pushing latest and tagVersion causes the push of latest to work, and the push of tagVersion fails in the exact same manner as shown here.

      I also verified that:
      docker tag --force=true eu.gcr.io/erento-docker/gradle eu.gcr.io/erento-docker/gradle:3.3-1 - fails on console
      docker tag eu.gcr.io/erento-docker/gradle eu.gcr.io/erento-docker/gradle:3.3-1 - does not fail on console

      Please let me know if I can provide any more data useful for fixing this.

            Unassigned Unassigned
            wduda Wojciech Duda
            4 Vote for this issue
            18 Start watching this issue