本文介绍了从Jenkins Pipeline发布到Artifactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Jenkins(v2.7)管道发布到Artifactory(v4.5.1)实例.下面是我脚本的摘录.问题似乎是无法识别"Artifactory"对象并将其视为字符串.有人可以建议出什么问题吗?

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
}

推荐答案

我在语法方面取得了成功:

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.

这篇关于从Jenkins Pipeline发布到Artifactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:33