我正在使用Jenkins - Groovy脚本,从jfrog artifactory上传和下载工件。
以下是上传和下载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的新手
答案 0 :(得分: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”周围没有括号