publishing to Artifactory from Jenkins Pipeline

萝らか妹 提交于 2019-12-11 06:08:23

问题


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
}

回答1:


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.



来源:https://stackoverflow.com/questions/38878620/publishing-to-artifactory-from-jenkins-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!