我按照本頁給出的例子,從JFrog artifactory下載工件。 https://www.jfrog.com/confluence/display/JFROG/Scripted Pipeline Syntax#ScriptedPipelineSyntax-UploadingandDownloadingFiles/a>
但是我一直得到NullPointerException。下面是腳本的輸出和錯誤:
[Pipeline] echo
下載規格 {
"檔案"。[
{
"模式": "aod-libs-release/path-to-artifact/deployment/DM-DP-V3A.24-RELEASE/deployment-DM-DP-V3A.24-RELEASE.zip"。
"目標"。"./artifacts"
}, {
"模式": "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"。
"目標"。"./artifacts"
}
]
}
[管道] echo
artifactory服務器 org.jfrog.hudson.pipeline.common.types.ArtifactoryServer@66026154
[管道] newBuildInfo
[管道] artifactoryDownload
[管線] 管線結束
java.lang.NullPointerException
at org.jfrog.hudson.pipeline.common.executors.GenericDownloadExecutor.executor(GenericDownloadExecutor.java:52)
at org.jfrog.hudson.pipeline.scripted.step.DownloadStep$Execution.runStep(DownloadStep.java:67)
at org.jfrog.hudson.pipeline.scripted.step.DownloadStep$Execution.runStep(DownloadStep.java:53)
at org.jfrog.hudson.pipeline.ArtifactorySynchronousNonBlockingStepExecution.run(ArtifactorySynchronousNonBlockingStepExecution.java:54)
at org.jenkinsci.plugins.workflow.step.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)
在java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
在java.lang.Thread.run(Thread.java:748)
完成了。失敗
下面是我的Jenkins流水線腳本
def artifactoryServer = Artifactory.server("Artifactory-instance-id")
artifactoryServer.connection.timeout = 300
def artifactDownloadSpec = ""{
"檔案"。[
{
"模式": "aod-libs-release/path-to-artifact/deployment/${env.DP_VERSION}/deployment-${env.DP_VERSION}.zip"。
"目標"。"./artifacts"
}, {
"模式": "aod-libs-release/path-to-artifact/dm-auth-web-services/${env.VERSION}/dm-auth-web-services-${env.VERSION}.war"。
"目標"。"./artifacts"
}
]
}"""
echo "download spec " artifactDownloadSpec
echo "artifactory server " artifactoryServer
artifactoryServer.download spec: artifactDownloadSpec
我在谷歌上搜索了GenericDownloadExecutor.java,發現了下面的代碼,但無法弄清楚我缺少的第52行需要什么。看起來像是一個欄位沒有被設定。
請幫助。事先謝謝你,祝你有個美好的一天。
uj5u.com熱心網友回復:
運行artifactoryServer.download步驟需要使用一個代理。
例如:
Jenkins的腳本流水線
節點 {
...
artifactoryServer.download spec: artifactDownloadSpec
...
}
Jenkins宣告式管道
推薦的方式是使用rtDownload步驟,然而,如果你仍然想使用artifactoryServer.download:
pipeline {
agent any // <- 確保有一個活動的代理
階段 {
stage('Example') {
步驟 {
腳本 {
...
artifactoryServer.download spec: artifactDownloadSpec
...
}
}
}
}
}
閱讀全文:
- Uploading and Downloading Files
- Scripted pipeline example 。
- 宣告式管道范例 。
- 宣告式管道內的腳本式管道示例 - 不太推薦,但這個例子就像你的情況 。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/318086.html
標籤:
