在Jenkins的job-dsl-plugin中使用时,CopyArtifacts(...)给出错误

时间:2014-02-14 18:25:47

标签: jenkins jenkins-plugins dsl jenkins-job-dsl

我尝试使用CopyArtifacts()以及编写自定义配置块来复制上游构建中的工件。我在两者中都得到了错误,如下所示 -

FATAL: No signature of method: javaposse.jobdsl.dsl.Job.CopyArtifacts() is applicable for argument types: (java.lang.String, java.lang.String, jobDSL$_run_closure1_closure4_closure14) values: [xxx-StarTrooper-master.unity, target/**, jobDSL$_run_closure1_closure4_closure14@a1994b]
groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.Job.CopyArtifacts() is applicable for argument types: (java.lang.String, java.lang.String, jobDSL$_run_closure1_closure4_closure14) values: [xxx-StarTrooper-master.unity, target/**, jobDSL$_run_closure1_closure4_closure14@a1994b]
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
    at jobDSL$_run_closure1_closure4.doCall(jobDSL.groovy:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

我的代码段如下 -

CopyArtifacts(downstreamUnityJob.name,'target/**'){ 
    buildNumber("${UNITY_BUILD_NUMBER}") 
}

当我尝试自定义配置块时,我也会收到错误 -

FATAL: No signature of method: groovy.util.Node.call() is applicable for argument types: (java.lang.String) values: [xxx-StarTrooper-master.unity]
Possible solutions: wait(), name(), value(), any(), wait(long), get(java.lang.String)
groovy.lang.MissingMethodException: No signature of method: groovy.util.Node.call() is applicable for argument types: (java.lang.String) values: [xxx-StarTrooper-master.unity]
Possible solutions: wait(), name(), value(), any(), wait(long), get(java.lang.String)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
    at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at jobDSL$_run_closure1_closure4_closure14_closure16.doCall(jobDSL.groovy:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

这是我的配置块 -

configure {
    project -> project/ builders / 'hudson.plugins.copyartifact.CopyArtifact'{
        projectName downstreamUnityJob.name //downstreamUnityJob comes from another job dsl object 
        project downstreamUnityJob.name
        filter 'target/**'
        selector('class':"hudson.plugins.copyartifact.SpecificBuild"){
            buildNumber "$UNITY_BUILD_NUMBER"
        }
    }
}

你能让我知道我错过了什么吗?

3 个答案:

答案 0 :(得分:2)

在JobDsl中,copyArtifacts需要以小写c开头(而不是大写字母C)

请参阅此处Job dsl wikiStepContext.copyArtifacts

答案 1 :(得分:0)

啊,我遇到了同样的问题。

  configure { project ->
    project / builders << 'hudson.plugins.copyartifact.CopyArtifact' {
      project(value.deps.get(0))
      filter(value.ins)
      target('')
      buildChooser(class: 'hudson.plugins.copyartifact.SpecificBuildSelector') {
        buildNumber('${parentBuildNo}')
      }
      doNotFingerprintArtifacts(true)
    }
  }

为我带来FATAL: No signature of method: groovy.util.Node.call()

我通过将要修改的XML元素的名称从project更改为myProject来解决此问题。由于配置块中的project修饰符会影响您正在修改的元素的名称,因此必须为闭包参数使用不同的名称。

  configure { myProject ->
    myProject / builders << 'hudson.plugins.copyartifact.CopyArtifact' {
      project(value.deps.get(0))
      filter(value.ins)
      target('')
      buildChooser(class: 'hudson.plugins.copyartifact.SpecificBuildSelector') {
        buildNumber('${parentBuildNo}')
      }
      doNotFingerprintArtifacts(true)
    }
  }

成功!

答案 2 :(得分:0)

对于您的问题,您应该使用delegate属性。

您的元素可能与另一个元素发生冲突。

以下是一个例子:

      configure { project ->
      project / builders << 'hudson.plugins.copyartifact.CopyArtifact' {
        delegate.project 'BLABLA' // DELEGATE
        ...
     }