Search code examples
jenkinsjenkins-pipelineartifactory

Get artifacts URL after rtUpload in Jenkins pipeline


Im using jenkins artifactory plugin and uploading tar file using rtUpload. Is there a way to get the artifact URI when it finished?

It does print it as a log :

[Pipeline] rtUpload

17:01:50 [consumer_0] Deploying artifact: http://x.x.x.x:8081/artifactory/my-local/snapshot/mor_v.tar.gz.


Solution

  • This functionality is only available on scripted pipeline at the moment, and is described in the documentation.

    For example:

    node {
    def server = Artifactory.server SERVER_ID
    def uploadSpec = readFile 'uploadSpec.json'
    def buildInfo = server.upload spec: uploadSpec
    
    if (buildInfo.getArtifacts().size() > 0) {
        def localPath = buildInfo.getArtifacts()[0].getLocalPath()
        def remotePath = buildInfo.getArtifacts()[0].getRemotePath()
        def md5 = buildInfo.getArtifacts()[0].getMd5()
        def sha1 = buildInfo.getArtifacts()[0].getSha1()
        echo remotePath
    }
    
    server.publishBuildInfo buildInfo
    }