Jordan
Jordan

Reputation: 9114

Jenkins pipeline + Artifactory download not downloading

I'm having trouble downloading a build from my artifactory server to my windows jenkins slave node using the jenkins pipeline plugin. It all appears to be going fine, but it doesn't actually download the file. Am I doing something wrong?

I don't see any requests in my Artifactory system logs to download, just to upload.

(2017-04-25 18:39:48,096 [http-nio-8081-exec-2] [INFO ] (o.a.e.UploadServiceImpl:516) - Deploy to 'BUILDS:windows/5840/build.tar.gz' Content-Length: 278600525)

I've been using this as a reference: https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=99910084


Here's the output from my jenkins pipeline:

For pattern: build.tar.gz 1 artifacts were found.
Deploying artifact: http://myartifactory:8081/artifactory/BUILDS/windows/5840/build.tar.gz
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] timeout
Timeout set to expire in 3 min 0 sec
[Pipeline] {
[Pipeline] node
Running on test-windows-0 in C:/jenkinsroot/workspace/test-windows
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
{
        "files": [
                {
                    "pattern": "BUILDS/windows/5840/build.tar.gz",
                    "target": "download/",
                }
            ]
        }
[Pipeline] echo
Artifactory Download: BUILDS/windows/5840/build.tar.gz -> download/

The file exists on artifactory.


Here's my jenkins code:

@NonCPS
def downloadArtifactory(String localPath, String repository, String remotePath) {

    def downloadSpec = """{
        "files": [
                {
                    "pattern": "${repository}/${remotePath}",
                    "target": "${localPath}",
                }
            ]
        }"""

    echo "${downloadSpec}"

    echo "Artifactory Download: ${repository}/${remotePath} -> ${localPath}"

    def server = Artifactory.server("MYARTIFACTORYSERVER")
    def buildInfo = server.download spec: downloadSpec
    return buildInfo
}

Called with:

downloadArtifactory("download/", "BUILDS", "windows/5840/build.tar.gz")

Upvotes: 1

Views: 10312

Answers (2)

Please remove the ,(comma) from the line "target": "${localPath}"

,

It works make it,

def downloadArtifactory(String localPath, String repository, String remotePath) {

def downloadSpec = """{
    "files": [
            {
                "pattern": "${repository}/${remotePath}",
                "target": "${localPath}"
            }
        ]
    }"""

echo "${downloadSpec}"

echo "Artifactory Download: ${repository}/${remotePath} -> ${localPath}"

def server = Artifactory.server("MYARTIFACTORYSERVER")
def buildInfo = server.download spec: downloadSpec
return buildInfo

}

Upvotes: 0

Dima Nevelev
Dima Nevelev

Reputation: 408

Removing the NonCPS annotation should solve the problem.
As you can see in this Jenkins issue, Artifactory Jenkins plugin does not support NonCPS.

Upvotes: 4

Related Questions