Uploaded image for project: 'Jenkins Artifactory Plug-in'
  1. Jenkins Artifactory Plug-in
  2. HAP-1465

Promotion of duplicated broken

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 3.8.0, 3.9.0, 3.10.1, 3.11.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      This kind of promotion was working with Plugin 3.6.1
      Artifactory: 6.20.1
      Jenkins: 2.2.774

    • Regression:
      Yes

      Description

      When promoting a build that contains artifacts with same name and same checksum the promotion does not work properly any longer.

      How to reproduce

      You need two artifacts folder1/aFile.txt and folder2/aFile.txt which have the same checksum. After upload the build and publishing start promoting it:

      1. After first promotion step, one artifact will remain in initial repo but second will be promoted.
      2. After second promotion step, artifact that stayed in inital repo will be promoted, but other one will remain in second promotion step.

      We have not faced this issue with Plugin version 3.6.1.

      Use the following jenkinsfile in order to reproduce this issue:

      // ------ Configure here ------------// Define your artifactory server herertServer = Artifactory.server 'artifactory-1'
      // Define three different repos that will be used for promotion steps// All repos are generic repos.def repo1 = "dev"def repo2 = "test"def repo3 = "prerelease"// ---------- Configuration end -----
      def buildInfo
      def showFiles(repo){    sh "wget --spider --output-file=wgetlog.txt -r -np --cut-dirs=3 -nv --reject=html,md5,sha1,sha256 ${rtServer.url}/$repo/test/$BUILD_NUMBER/"    sh "sed -n -e 's/.*URL: //p' wgetlog.txt > res.log"    print "Show Files for $repo:"    sh "cat res.log"}
      pipeline {    agent any
          stages {        stage('Build (gerate some files)') {            steps {                print(rtServer.url)                sh "echo 'aFile1' > aFile1.txt"                sh "echo 'aFile2' > aFile2.txt"                sh "echo 'bFile1' > bFile1.txt"                sh "echo 'bFile2' > bFile2.txt"                sh "mkdir -p copies"                // Copy of aFile must have same filename                // If filename is different promotion works well.                sh "cp aFile1.txt copies/aFile1.txt"            }        }        stage('Image deploy') {            steps {                 script {                     // ---- 1. Upload files ----                     // Files get uploaded into different target folders                     buildInfo = Artifactory.newBuildInfo()                                          def uploadImagesSpec = """{                        "files": [                            {                                "pattern":   "$WORKSPACE/aFile*",                                "target":    "$repo1/test/$BUILD_NUMBER/aFiles/"                            }                        ]                     }"""                     rtServer.upload(spec: uploadImagesSpec, buildInfo: buildInfo)                                          uploadImagesSpec = """{                        "files": [                            {                                "pattern":   "${WORKSPACE}/bFile*",                                "target":    "$repo1/test/$BUILD_NUMBER/bFiles/"                            }                        ]                     }"""                     rtServer.upload(spec: uploadImagesSpec, buildInfo: buildInfo)
                           uploadImagesSpec = """{                        "files": [                            {                                "pattern":   "${WORKSPACE}/copies/*",                                "target":    "$repo1/test/$BUILD_NUMBER/copiedFiles/"                            }                        ]                     }"""                     rtServer.upload(spec: uploadImagesSpec, buildInfo: buildInfo)                     buildInfo.env.collect()                     // ----- 2. Publish Build Info ----                     rtServer.publishBuildInfo buildInfo                     // !!! buildInfo only contains "orignal" file, but not copy !!!                     print(buildInfo.getArtifacts())                }            }        }        stage('Promot to test repo') {            steps {                 script {                    // ----- Promote firt time to test repo -----                    def promoteConfig  = [                        'targetRepo'    : repo2,                        'comment'       : "Released to testing",                        'status'        : "testing",                        'buildName'     : buildInfo.name,                        'buildNumber'   : buildInfo.number,                        'failFast'      : true,                        'includeDependencies': true                    ]                                        rtServer.promote(promoteConfig)
                          // !!! Dev repo still contains the copied file                    // it gets not promoted.                    showFiles(repo1)                    // !!! All the other files are promoted                    showFiles(repo2)                 }            }        }        stage('Promote to prerelease repo') {            steps {                 script {                    // Show all files in first repo, all is ok.                    showFiles(repo1)                                        // ------ Promote second time to prerelease repo ------                    def promoteConfig  = [                        'targetRepo'    : repo3,                        'comment'       : "Promote to prerelease",                        'status'        : "prerelease",                        'buildName'     : buildInfo.name,                        'buildNumber'   : buildInfo.number,                        'failFast'      : true,                        'includeDependencies': true                    ]                                        rtServer.promote(promoteConfig)
                          // Initlal Repo (dev) is empty, no more files from this build here.                    showFiles(repo1)                    // !!! The original, not copied file stays in test repo.                    showFiles(repo2)                    // !!! The Copied file jumps over the test repo and goes into the                    // prerelease repo directly.                    showFiles(repo3)                 }            }        }    }        }
      
      

      Additional information:

      • Check the buildInfo after all artifacts have been uploaded: It already has filtered out the copied artifact.
      • We checked the buildinfo on Artifactory. Builds published and promoted with plugins 3.8.0 and onward don't have the remotePath in the buildInfo.

        Attachments

          Activity

            People

            Assignee:
            eyalb Eyal Ben Moshe
            Reporter:
            samuel.bissig2 Samuel Bissig
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: