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.

      #!groovy
      // 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.

          [JENKINS-42152] Docker Pipeline causes build to fails because of use of --force=yes for tagging

          Wojciech Duda created issue -

          Wojciech Duda added a comment - - edited

          I also tried writing the last stage as:

            stage('publish image') {
              myImage.push("${tagVersion}")
              myImage.push('latest')
            }
          

          with exactly the same result.

          Wojciech Duda added a comment - - edited I also tried writing the last stage as: stage( 'publish image' ) { myImage.push( "${tagVersion}" ) myImage.push( 'latest' ) } with exactly the same result.

          Wojciech Duda added a comment -

          Looking at https://issues.jenkins-ci.org/browse/JENKINS-41148?focusedCommentId=284247&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-284247,

          the fix introduced in v1.4 of the plugin was temporary and does not work if you try to execute on Docker 1.12

          Wojciech Duda added a comment - Looking at https://issues.jenkins-ci.org/browse/JENKINS-41148?focusedCommentId=284247&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-284247 , the fix introduced in v1.4 of the plugin was temporary and does not work if you try to execute on Docker 1.12

          Wojciech Duda added a comment -

          Added pull request at https://github.com/jenkinsci/docker-workflow-plugin/pull/90 , code reviews welcome.

          Wojciech Duda added a comment - Added pull request at https://github.com/jenkinsci/docker-workflow-plugin/pull/90 , code reviews welcome.

          Jack Brooks added a comment -

          wduda, thanks for creating the PR! This is definitely still an issue. Hopefully we'll see that merged soon.

          Jack Brooks added a comment - wduda , thanks for creating the PR! This is definitely still an issue. Hopefully we'll see that merged soon.

          Wojciech Duda added a comment -

          Will update the PR today, seems it is not working for everyone.

           

          Wojciech Duda added a comment - Will update the PR today, seems it is not working for everyone.  

          Wojciech Duda added a comment -

          I did a small update to the PR but that was done blind, had no time to test it. WIll be able to do that tomorrow evening CEST, if somebody wants to try in the meantime please let me know about your results.

          Wojciech Duda added a comment - I did a small update to the PR but that was done blind, had no time to test it. WIll be able to do that tomorrow evening CEST, if somebody wants to try in the meantime please let me know about your results.

          Jack Brooks added a comment -

          wduda, I'm assuming that to test this we need to build a plugin from your fork, correct? (Sorry, still really cutting my teeth on Jenkins.)

          Jack Brooks added a comment - wduda , I'm assuming that to test this we need to build a plugin from your fork, correct? (Sorry, still really cutting my teeth on Jenkins.)
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-41140 [ JENKINS-41140 ]

          Is there any update as to when this will be fixed or if there is a workaround?

          Nick Aslanidis added a comment - Is there any update as to when this will be fixed or if there is a workaround?

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

              Created:
              Updated: