jenkins管道在www.example.com上产生无法解释的NullPointerExceptionGenericDownloadExecutor.java:52

yc0p9oo0  于 2023-01-25  发布在  Jenkins
关注(0)|答案(1)|浏览(104)

我按照本页中给出的示例从JFrog artifactory下载工件:https://www.jfrog.com/confluence/display/JFROG/Scripted+Pipeline+Syntax#ScriptedPipelineSyntax-UploadingandDownloadingFiles
但是我一直收到NullPointerException。下面是脚本输出和错误:

[Pipeline] echo
download spec {
    "files": [
        {
            "pattern": "aod-libs-release/path-to-artifact/deployment/DM-DP-V3A.24-RELEASE/deployment-DM-DP-V3A.24-RELEASE.zip",
            "target": "./artifacts"
        }, {
            "pattern": "aod-libs-release/path-to-artifact/dm-auth-web-services/DM-AU-V3A.88-RELEASE/dm-auth-web-services-DM-AU-V3A.88-RELEASE.war",
            "target": "./artifacts"
        }
    ]
}
[Pipeline] echo
artifactory server org.jfrog.hudson.pipeline.common.types.ArtifactoryServer@66026154
[Pipeline] newBuildInfo
[Pipeline] artifactoryDownload
[Pipeline] End of Pipeline
java.lang.NullPointerException
    at org.jfrog.hudson.pipeline.common.executors.GenericDownloadExecutor.execute(GenericDownloadExecutor.java:52)
    at org.jfrog.hudson.pipeline.scripted.steps.DownloadStep$Execution.runStep(DownloadStep.java:67)
    at org.jfrog.hudson.pipeline.scripted.steps.DownloadStep$Execution.runStep(DownloadStep.java:53)
    at org.jfrog.hudson.pipeline.ArtifactorySynchronousNonBlockingStepExecution.run(ArtifactorySynchronousNonBlockingStepExecution.java:54)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

下面是我的Jenkins管道脚本

def artifactoryServer = Artifactory.server("Artifactory-instance-id")
artifactoryServer.connection.timeout = 300
def artifactDownloadSpec = """{
    "files": [
        {
            "pattern": "aod-libs-release/path-to-artifact/deployment/${env.DP_VERSION}/deployment-${env.DP_VERSION}.zip",
            "target": "./artifacts"
        }, {
            "pattern": "aod-libs-release/path-to-artifact/dm-auth-web-services/${env.VERSION}/dm-auth-web-services-${env.VERSION}.war",
            "target": "./artifacts"
        }
    ]
}"""

echo "download spec " + artifactDownloadSpec
echo "artifactory server " + artifactoryServer
artifactoryServer.download spec: artifactDownloadSpec

我在谷歌上搜索了GenericDownloadExecutor.java,找到了下面的代码,但无法找出我缺少的第52行所需的内容。看起来像是一个字段没有设置。
https://github.com/jenkinsci/artifactory-plugin/blob/master/src/main/java/org/jfrog/hudson/pipeline/common/executors/GenericDownloadExecutor.java

gt0wga4j

gt0wga4j1#

运行artifactoryServer.download步骤需要使用代理。例如:

    • Jenkins编写的销售管道**
node {
  ...
  artifactoryServer.download spec: artifactDownloadSpec
  ...
}
    • Jenkins申报管道**

但是,如果您仍然希望使用artifactoryServer.download,建议使用rtDownload步骤:

pipeline {
    agent any // <- Make sure there is an active agent
    stages {
        stage('Example') {
            steps {
                script {
                  ...
                  artifactoryServer.download spec: artifactDownloadSpec
                  ...
                }
            }
        }
    }
}

阅读详情:
1.上载和下载文件

  1. Scripted pipeline example
  2. Declarative pipeline example
  3. Scripted pipeline inside declarative pipeline example-不太推荐,但此示例与您的情况类似

相关问题