You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Sven Schott <sv...@gmail.com> on 2016/01/10 23:53:50 UTC

Method parameters changed when calling HTTPClient.addRequestInterceptor()

Hi all,

I'm relatively new to Groovy (I mostly use it for scripting Jenkins and
JIRA) and I have a problem with a script I'm trying to run on Jenkins. I
think it may be language related (so not a bug per se) so I thought I would
post it here.

I'm using the HTTPBuilder library to make REST calls to JIRA from Jenkins.
I am also using the Jenkins Groovy Postbuild plugin to trigger the script
which handles this. The script works fine (connects to JIRA and creates or
modifies an issue) but I decided I wanted to call it from another script (
a loader, so to speak ), so I wrapped the script into a class. This fails
with a "No signature of method" error. The problem appears to be the
request interceptor that handles authentication. The loader calls two
different scripts, both of them which use HTTPBuilder to connect to HTTP
services but only the script with the request interceptor fails. The bit of
offending code is this:

https://gist.github.com/genericpenguin/7f3b5edafecfb335ac16

com.bigworldtech.ci.JiraConnection is the class that contains the code,
although it is not part of the script (it is loaded from the JAR that
contains all the classes). Somehow, the HTTPClient object is being passed a
reference is being passed a reference to its containing instance, rather
than the interceptor object I am literally passing in code.

The funny thing is that when the class that contains the script is removed
(i.e. the class declaration is stripped), and the script is placed directly
into the postbuild plugin script entry, the script works fine. We have been
using it for several months and have only encountered this issue when it
has been placed in it's own class.

I'm guessing there might be some dynamic fanciness happening that I don't
understand, but I don't really know where to start investigating. I've
tried setting the username and password in the standard way but that
doesn't work because JIRA is set to not challenge for authentication. I've
also tried constructing the interceptor separately and passing the
reference but it was the same.

I'm hoping someone with more knowledge of Groovy might be able to point me
in the right direction.

Regards

Sven Schott