John Cartwright
John Cartwright

Reputation: 599

publishing to Artifactory from Jenkins Pipeline

I'm trying to publish to an Artifactory (v4.5.1) instance using a Jenkins(v2.7) pipeline. An excerpt from my script is below. Problem seems to be that the "Artifactory" object is not recognized and is treated as a string. Can someone suggest what the problem might be?

node {
 //error - "Artifactory" treated as String 
 def server = Artifactory.server SERVER_ID

  def uploadSpec = """{
    "files": [
            {
                "pattern": "hello-pipeline/build/libs/*.jar",
                "target": "jenkins-local"
            }
        ]
    }"""

  def buildInfo1 = server.upload spec: uploadSpec
}

Upvotes: 2

Views: 10855

Answers (1)

tessafyi
tessafyi

Reputation: 2343

I've had success with the syntax:

node {
 def server = Artifactory.server SERVER_ID

  def uploadSpec = """{
    "files": [{
                "pattern": "hello-pipeline/build/libs/*.jar",
                "target": "jenkins-local"
            }
        ]
    }"""

  server.upload(uploadSpec)
}

as was suggested on another question. However, this could be an issue with your version, as mention in the the comment above.

Upvotes: 2

Related Questions