Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-65609

Groovy With method doesn't work as expected

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Use of extended method with in Groovy result in a groovy.lang.MissingMethodException.

      This code portion work well in pure groovy not in a grovvy pipeline :

      HttpURLConnection connection = baseUrl.openConnection() as HttpURLConnection
      connection.with {
          setDoOutput(true)
          setRequestProperty('Content-Type', 'application/json')
          setRequestProperty('Authorization', httpUtils.getBasicAuthString(Credentials.JENKINS_ARTIFACTORY_TOKEN.value))
          requestMethod = 'POST'
          outputStream.withWriter { writer ->
              writer << queryString
          }
          assert responseCode == 200
      }
      
      

      Result in the exception :

      hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: fr.hm.pichm.tools.publication.ArtifactoryPromote.setDoOutput() is applicable for argument types: (java.lang.Boolean) values: [true]
       at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
       at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
       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:20)

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            wildagsx St├ęphane Philippart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: