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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: docker-workflow-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.32.2
      Docker 1.12.3
      Docker Pipeline Plugin 1.10
    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Josh Mesilane yes that is a user error, mentioned months ago IIRC in some open PR in this plugin. The upshot is that attempts to pass a malformed tag should fail fast.

            Show
            jglick Jesse Glick added a comment - Josh Mesilane yes that is a user error, mentioned months ago IIRC in some open PR in this plugin. The upshot is that attempts to pass a malformed tag should fail fast.
            Hide
            vadimo Vadimo added a comment -

            We have Docker Pipeline Plugin 1.10 Jenkins ver. 2.73

            we see exact the same issue:

            Successfully built 3e1c5820e826
            Successfully tagged docker.8gears.com/pdr/helmsman:latest
            [Pipeline] dockerFingerprintFrom
            [Pipeline] sh
            [workspace] Running shell script
            + docker tag --force=true docker.8gears.com/pdr/helmsman docker.8gears.com/pdr/helmsman:latest
            unknown flag: --force
            See 'docker tag --help'.
            + docker tag docker.8gears.com/pdr/helmsman docker.8gears.com/pdr/helmsman:latest
            [workspace] Running shell script
            [Pipeline] sh
            + docker push docker.8gears.com/pdr/helmsman:latest
            The push refers to a repository [docker.8gears.com/pdr/helmsman]
            

            this is the stage

             

                  stage("build") {
                    steps {
                      script {
                          def helmsmanImage = docker.build("docker.8gears.com/pdr/helmsman")
                          helmsmanImage.push('latest')
                      }
                    }
                  }
            
            Show
            vadimo Vadimo added a comment - We have Docker Pipeline Plugin 1.10 Jenkins ver. 2.73 we see exact the same issue: Successfully built 3e1c5820e826 Successfully tagged docker.8gears.com/pdr/helmsman:latest [Pipeline] dockerFingerprintFrom [Pipeline] sh [workspace] Running shell script + docker tag --force= true docker.8gears.com/pdr/helmsman docker.8gears.com/pdr/helmsman:latest unknown flag: --force See 'docker tag --help' . + docker tag docker.8gears.com/pdr/helmsman docker.8gears.com/pdr/helmsman:latest [workspace] Running shell script [Pipeline] sh + docker push docker.8gears.com/pdr/helmsman:latest The push refers to a repository [docker.8gears.com/pdr/helmsman] this is the stage   stage("build") { steps { script { def helmsmanImage = docker.build("docker.8gears.com/pdr/helmsman") helmsmanImage.push('latest') } } }
            Hide
            jglick Jesse Glick added a comment -

            Vadimo as you can see, the tagging and pushing succeeds—as designed.

            Show
            jglick Jesse Glick added a comment - Vadimo as you can see, the tagging and pushing succeeds—as designed.
            Hide
            spacez320 Matthew Coleman added a comment - - edited

            If you're using Declarative Pipeline, I was able to push two tags of the same image, one latest and one using the commit, doing the following:

            stage("checkout') {
              steps {
                script {
                  # Parse the revision.
                  sh 'git rev-parse HEAD > .rev'
                  rev = readFile('.rev').trim()
                }
              }
            }
            ... other things ...
            stage('publish') {
              steps {
                script {
                  image.push rev
                  image.push 'latest'
                }
              }
            }

            The `trim()` call is key, otherwise you get errors mentioned in this issue.

            Show
            spacez320 Matthew Coleman added a comment - - edited If you're using Declarative Pipeline, I was able to push two tags of the same image, one latest and one using the commit, doing the following: stage("checkout') { steps { script { # Parse the revision. sh 'git rev-parse HEAD > .rev' rev = readFile( '.rev' ).trim() } } } ... other things ... stage( 'publish' ) { steps { script { image.push rev image.push 'latest' } } } The `trim()` call is key, otherwise you get errors mentioned in this issue.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Aaron Weiker
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            http://jenkins-ci.org/commit/docker-workflow-plugin/c961afc373ca9cb65051865e6d6651c1911f620d
            Log:
            JENKINS-42152 Do not use --force when tagging images

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Aaron Weiker Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy http://jenkins-ci.org/commit/docker-workflow-plugin/c961afc373ca9cb65051865e6d6651c1911f620d Log: JENKINS-42152 Do not use --force when tagging images

              People

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

                Dates

                • Created:
                  Updated: