0

I use Jenkins Artifactory Plug-in for promotion. I try to create separate job to promote the artifact. Here the stage of promotion

stage('promote artifact') {
        steps {
            script {
                String buildName = "${BUILD_NAME}"
                String buildNumber = "${BUILD_NUMBER}"
                def promotionConfig = [
                //Mandatory parameters
                'buildName'          : buildName,
                'buildNumber'        : buildNumber,
                'targetRepo'         : "tst",

                //Optional parameters
                'comment'            : "this is the promotion comment",
                'sourceRepo'         : "dev",
                'status'             : "Released",
                'includeDependencies': true,
                'failFast'           : true,
                'copy'               : true
            ]

            // Promote build
            server.promote promotionConfig
            }
        }
    }

As BUILD_NAME I try name of commit job and name of artifact at snapshot repository As BUILD_NUMBER I use number of build like 1 without version number like 1.0.0. But after all I got

Performing dry run promotion (no changes are made during dry run) ... 
ERROR: Promotion failed during dry run (no change in Artifactory was done): HTTP/1.1 404 Not Found
 {
   "errors" : [ {
     "status" : 404,
     "message" : "Cannot find builds by the name 'artifact-name' and the number '1'."
  } ]
 }

Do you have some idea how to run it successfully? Or some flag to get more information about this error?

Risha
  • 45
  • 1
  • 7

1 Answers1

0

The reason why it fails for me that I skipped part with upload build info to Artifactory. You should create the upload spec during build task and upload it to Artifactory. BuildInfo will be stored separately and contains service infromation. After that promotion will work fine.

def uploadSpec = """{
  "files": [
    {
      "pattern": "bazinga/*froggy*.zip",
      "target": "bazinga-repo/froggy-files/"
    }
 ]
}"""
server.upload(uploadSpec)
Risha
  • 45
  • 1
  • 7