Upload failed with MissingMethodException when called from Pipeline Shared Library

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: artifactory-plugin
    • None
    • Environment:
      Windows 7,
      Jenkins ver. 2.46.1,
      Artifactory Plugin ver. 2.10.3, Pipeline plugin ver. 2.5, Pipeline: Shared Groovy Libraries plugin ver. 2.7

      Hello!

      I am using the Artifactory plugin successfully for uploading files to my repository on Artifactory. This is the corresponding pipeline script: 

      def myUploadFunc(String artifactoryServerName, String sourcePath, String destinationPath) {
          /* Create an Artifactory Server Instance */
          def server = Artifactory.server artifactoryServerName
          /* Create Download Spec */
          def uploadSpec = """{
              "files": [
                  {
                      "pattern": "${sourcePath}/*.*",
                      "target": "${destinationPath}"
                  }
              ]
          }"""
          /* Upload files to Artifactory */
          def buildInfoUpload = server.upload(uploadSpec)
          /* Publish Build-Info to Artifactory */
          server.publishBuildInfo(buildInfoUpload)
      }
      
      

       Now I want to make it a Shared Library function. I defined a global variable as follows:

      File name: artifactoryUpload.groovy

       

      // vars/artifactoryUpload.groovy
      def call(String artifactoryServerName, String sourcePath, String destinationPath) {
       /* Create an Artifactory Server Instance */
       def server = Artifactory.server artifactoryServerName
       
       /* Create Upload Spec */
       def uploadSpec = """{
           "files": [
               {
                   "pattern": "${sourcePath}/*.*",
                   "target": "${destinationPath}"
               }
          ]
       }"""
       
       /* Upload files to Artifactory */
       def buildInfoUpload = server.upload(uploadSpec) //LINE 18
       
       /* Publish Build-Info to Artifactory */
       server.publishBuildInfo(buildInfoUpload)
      }
      

       

      The library is used as follows:

      @Library("MyTestLib@V0.7-SNAPSHOT3") _
      
      timestamps {
          node("Bernd's PC") {
              stage ("Artifactory Upload") {
                  try {
                      def BASELINE_NAME = "20170410"
                      def RESULTS_PATH = "d:/temp/to_be_deleted/2017_04_07/results/"
                      def artifactoryServerName = 'cofa-artifactory'
                      def destinationPath = "TestRepoForJenkins/JFrog_Plugin/testreports/${BASELINE_NAME}/"
                      artifactoryUpload(artifactoryServerName, RESULTS_PATH, destinationPath)
                  } catch (err) {
                      throw err
                  }
              }
          }
      }

      This is the respective error log:

      [Pipeline] getArtifactoryServer
       [Pipeline] echo*16:52:55* groovy.lang.MissingMethodException: No signature of method: artifactoryUpload.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[spec:{16:52:55 "files": [*16:52:55* \{*16:52:55* "pattern": "d:/temp/to_be_deleted/2017_04_07/results//*.*",*16:52:55* "target": "TestRepoForJenkins/JFrog_Plugin/testreports/20170410/"*16:52:55* }*16:52:55* ]16:52:55 }, ...]]16:52:55 Possible solutions: call(java.lang.String, java.lang.String, java.lang.String), wait(), any(), wait(long), main([Ljava.lang.String, any(groovy.lang.Closure)
       [Pipeline] }
       [Pipeline] // stage
       [Pipeline] }
       [Pipeline] // node
       [Pipeline] }
       [Pipeline] // timestamps
       [Pipeline] End of Pipeline
       hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: artifactoryUpload.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[spec:{
       "files": [
       {
       "pattern": "d:/temp/to_be_deleted/2017_04_07/results//.",
       "target": "TestRepoForJenkins/JFrog_Plugin/testreports/20170410/"
       }
       ]
       }, ...]]
       Possible solutions: call(java.lang.String, java.lang.String, java.lang.String), wait(), any(), wait(long), main([Ljava.lang.String, any(groovy.lang.Closure)
       at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
       at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:64)
       at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap.invoke(PojoMetaMethodSite.java:217)
       at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
       at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
       at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
       at artifactoryUpload.call(D:\GIT\ContiFactory\Jenkins\jobs\Test_ArtifactoryUpload\builds\22\libs\TestCoFaLib\vars\artifactoryUpload.groovy:18)
       at WorkflowScript.run(WorkflowScript:20)
       at __cps.transform__(Native Method)
       at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
       at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
       at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
       at sun.reflect.GeneratedMethodAccessor245.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
       at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
       at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
       at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
       at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
       at com.cloudbees.groovy.cps.Next.step(Next.java:74)
       at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
       at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
       at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
       at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:165)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
       at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
       at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
       at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
       Finished: FAILURE

      It points to the line where server.upload() is called.

      (...)
      artifactoryUpload.call(D:\GIT\ContiFactory\Jenkins\jobs\Test_ArtifactoryUpload\builds\22\libs\TestCoFaLib\vars\artifactoryUpload.groovy:18)
      (...)

      That's why I'm convinced that the shared library is used correctly and I assume that the rrot cause is located in the Artifactory plugin.

            Assignee:
            Eyal Ben Moshe
            Reporter:
            Bernd Pfaff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: