我不发布构建信息,因为该对象存在一些问题。如果我尝试添加buildInfo,则会出现进一步的错误,提示生成对象或某些不正确的内容:https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins#WorkingWithPipelineJobsinJenkins-PublishingBuild-InfotoArtifactory。
//Define artifactory server
//Definition by node-id does not seem to be working? 403, Jenkins system config is fine
def artifactory_server = Artifactory.server('artifactory-node1')
def RPM_ROOT = env.WORKSPACE + "/rpm-repo/simba-hive-jdbc/RPMS"
// Define upload spec for RPM uploads
// Does not currently notify you if 0 artifacts were found (BUG?)"
// "props": "type=rpm"
echo "Defining upload spec"
def uploadSpec = """{
"files": [
{
"pattern": "${RPM_ROOT}",
"target": "rhel-7/",
"recursive": "true"
}
]
}"""
上传:
stage('Upload RPM to Artifactory') {
echo "Verifying existance of file"
env.RPMPKG = sh(returnStdout: true, script: "find ${RPM_ROOT} -name simba-hive-jdbc*.rpm").trim()
if(fileExists(env.RPMPKG)) {
echo "Verified RPM: " + env.RPMPKG
} else {
error("RPM File not found! Aborting")
}
echo "Uploading RPM package to Artifactory"
// Set upload
def buildinfo = artifactory_server.upload(uploadSpec)
```
詹金斯:
+ find /opt/jenkins/workspace/operations-testing/simba-hive-jdbc/rpm-repo/simba-hive-jdbc/RPMS -name 'simba-hive-jdbc*.rpm'
[Pipeline] fileExists
[Pipeline] echo
Verified RPM: /opt/jenkins/workspace/operations-testing/simba-hive-jdbc/rpm-repo/simba-hive-jdbc/RPMS/x86_64/simba-hive-jdbc-4.1-1.el7.x86_64.rpm
[Pipeline] echo
Uploading RPM package to Artifactory
[Pipeline] newBuildInfo
[Pipeline] artifactoryUpload
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Cleanup)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline