简体   繁体   English

Jenkins 管道 + Artifactory 下载未下载

[英]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.我无法使用 jenkins 管道插件将构建从我的工件服务器下载到我的 windows jenkins 从节点。 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.我在 Artifactory 系统日志中没有看到任何下载请求,只是上传。

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

I've been using this as a reference: https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=99910084我一直在使用它作为参考: 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.该文件存在于 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")

Removing the NonCPS annotation should solve the problem.删除 NonCPS 注释应该可以解决问题。
As you can see in this Jenkins issue , Artifactory Jenkins plugin does not support NonCPS.正如您在此 Jenkins 问题中所见,Artifactory Jenkins 插件不支持 NonCPS。

Please remove the ,(comma) from the line "target": "${localPath}"请从 "target": "${localPath}" 行中删除 ,(comma)

, ,

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM