Jenkins-Groovy - Jfrog Artifactory - getting exception while downloading artifacts Calculated MD5 checksum is different from original

梦想的初衷 提交于 2020-01-16 07:32:28

问题


I am working with Jenkins - Groovy Script, uploading and downloading artifacts to and from jfrog artifactory.

Below is the code for upload and download zip folder.

 stage("Upload Artifact to Jfrog"){
    def server = Artifactory.server 'JfrogTAArtifactory'
      def uploadSpec = """{
      "files": [
        {
          "pattern": "${env.WORKSPACE}\\${artifactsfoldername}\\API-${env.BUILD_NUMBER}.zip",
          "target": "internal-repo/folderName/subFolder/",
          "props": "type=zip;status=ready"

        }
     ]
    }"""
    def buildInfo =  server.upload(uploadSpec)
    server.publishBuildInfo(buildInfo)
  }

stage("Download Artifacts"){
      def server = Artifactory.server 'JfrogTAArtifactory'
      File folder = new File(downloadArtifactsPath)
      FileUtils.cleanDirectory(folder)

      def downloadSpec = """{
         "files": [
          {
              "pattern": "internal-repo/folderName/subFolder/API-${env.BUILD_NUMBER}.zip",
              "target": "${downloadArtifactsPath}/",
              "explode":"true",
              "flat": "true"
            }
         ]
        }"""
     def buildInfo = server.download(downloadSpec)
      server.publishBuildInfo(buildInfo)
  }

When I try to download I am getting the following exception

java.io.IOException: Calculated MD5 checksum is different from original, Original: '09bb61772231822ebd37a2751c818f60' Calculated: '7e32b3f7e8149fbc8013fd7992f345e5'
at org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.validateMd5Checksum(DependenciesDownloaderHelper.java:439)

Can any one help me?. I am new to both jenkins and Jfrog


回答1:


This works for me:

// deploy/upload sublog file in job workspace to artifactory
// using jenkins artifactory plugin
def server = Artifactory.server 'ABCD'
server.username = 'XXXX'
server.password = 'YYYY'
// repo has name jenkinsbuilds/{job}/{build}
def buildnumber = env.BUILD_NUMBER
def jobname = env.JOB_NAME
def targetspec = 'jenkinsbuilds/' + jobname + '/' + buildnumber + '/'
def uploadSpec = '{"files": [{"pattern": "sublog","target": "' + targetspec + '"}]}'
def buildinfo = server.upload uploadSpec
server.publishBuildInfo buildinfo

Note no brackets around 'buildinfo' for server.publishBuildInfo call



来源:https://stackoverflow.com/questions/50490326/jenkins-groovy-jfrog-artifactory-getting-exception-while-downloading-artifac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!