【问题标题】:Jenkins pipeline + Artifactory download not downloadingJenkins管道+ Artifactory下载未下载
【发布时间】:2017-04-25 22:47:20
【问题描述】:

我无法使用 jenkins 管道插件将构建从我的工件服务器下载到我的 windows jenkins 从节点。 似乎一切正常,但实际上并没有下载文件。我做错了吗?

我在 Artifactory 系统日志中没有看到任何下载请求,只是上传。

(2017-04-25 18:39:48,096 [http-nio-8081-exec-2] [INFO] (o.a.e.UploadServiceImpl:516) - 部署到 'BUILDS:windows/5840/build.tar.gz'内容长度:278600525)

我一直以此为参考:https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=99910084


这是我的詹金斯管道的输出:

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/

该文件存在于工件上。


这是我的詹金斯代码:

@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
}

调用:

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

【问题讨论】:

  • 从您的 echo 语句看来,您的 def downloadSpec 正在创建一个名为 downloadSpec 的空变量。也许规范语句开头的三引号会混淆它,您只会得到前两个引号,将其分配为空字符串。
  • @Tuffwer:它似乎正在打印 downloadSpec 变量,不是吗?我使用相同的格式进行上传。我很困惑:)
  • 你说得对,我在那里读到了一个额外的回声声明。查看您提到的页面后,我想知道您是否需要以不同的方式调用下载。页面执行下载示例为server.download(downloadSpec)
  • 是的,我也试过了,很遗憾。这里的示例 (github.com/JFrogDev/project-examples/blob/master/…) 以我目前正在尝试的格式给出它
  • 尝试删除目标行末尾的逗号,在该部分规范的最后一行末尾没有一个示例有逗号。

标签: jenkins jenkins-plugins artifactory jenkins-pipeline


【解决方案1】:

删除 NonCPS 注释应该可以解决问题。
正如您在this Jenkins issue 中看到的,Artifactory Jenkins 插件不支持 NonCPS。

【讨论】:

  • 谢谢,明白了!
【解决方案2】:

请从 "target": "${localPath}" 行中删除 ,(逗号)

有效 做吧,

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

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-19
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多