0

我正在使用 Jenkins - Groovy 脚本,向 jfrog 工件上传和下载工件。

以下是上传和下载 zip 文件夹的代码。

 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)
  }

当我尝试下载时,出现以下异常

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)

谁能帮我?。我是 jenkins 和 Jfrog 的新手

4

1 回答 1

0

这对我有用:

// 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

注意 server.publishBuildInfo 调用的“buildinfo”周围没有括号

于 2018-07-26T13:40:30.350 回答