我正在尝试使用Jenkins Pipeline脚本将一些二进制文件上传到Artifactory。 我使用了Artifactory documentation中的相同例子,但它不起作用。 我有以下错误:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.upload() is applicable for argument types: (java.lang.String) values: [{
"files": [
....
还有另一个类似的question,但没有回应...
pipeline {
agent any
environment {
def server = Artifactory.server 'art-1'
def uploadSpec = """{
"files": [
{
"pattern": "path/",
"target": "path/"
}
]
}"""
}
stages {
stage('upload') {
steps {
script { server.upload(uploadSpec) }
}
}
}
}
Artifactory 5.4.6
答案 0 :(得分:5)
您没有正确使用声明性管道。环境部分不是这样的。你只能在那里定义字符串,我会认为def
会抛出错误,但显然不会。
最终,server
等于对Artifactory.server对象的引用的String表示形式。基本上是Artifactory.server.toString()。
试试这个:
pipeline {
agent any
stages {
stage('upload') {
steps {
script {
def server = Artifactory.server 'art-1'
def uploadSpec = """{
"files": [{
"pattern": "path/",
"target": "path/"
}]
}"""
server.upload(uploadSpec)
}
}
}
}
}
答案 1 :(得分:0)
我遇到一个问题,我使用的是正确的语法,没有看到任何错误,但仍然看不到工件上传。而不是像这样的Jenkins日志:
[Pipeline] { (upload)
[Pipeline] script
[Pipeline] {
[Pipeline] bat
[libraries_PR-1-WWJNY63HBCEAKKTFO6WL2V5LW] Running batch script
[Pipeline] getArtifactoryServer
[Pipeline] newBuildInfo
[Pipeline] artifactoryUpload
[consumer_0] Deploying artifact: https://my.artifactory.net/path/
[Pipeline] }
我看到了:
[Pipeline] { (upload)
[Pipeline] script
[Pipeline] {
[Pipeline] bat
[libraries_PR-1-WWJNY63HBCEAKKTFO6WL2V5LW] Running batch script
[Pipeline] getArtifactoryServer
[Pipeline] newBuildInfo
[Pipeline] artifactoryUpload
[Pipeline] }
这是因为未正确指定我的路径,因此没有文件与之匹配。更改路径会导致一切正常。