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

Exception thrown when overriding inherited method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • groovy-plugin
    • None
    • Jenkins 2.107.1, Groovy plugin 2.0

      I make significant use of the RESTClient library, in conjunction with the 'execute system groovy script' build step and the permissive script security plugin installed (I have other measures to prevent anyone else being able to run scripts on the box).  As part of this, setting authorisation headers requires the following code snippet:

      def myUser = "username"
      def myPassword = "password"
      def myUrl = "http://myJIRAHost/rest/api/latest/"
      def client = new RESTClient( myUrl )
      client.client.addRequestInterceptor(new HttpRequestInterceptor() {
        void process(HttpRequest httpRequest, HttpContext httpContext) {
          httpRequest.addHeader('Authorization', 'Basic ' + "${myUser}:${myPassword}".bytes.encodeBase64().toString())
        }
      })

       

      Previously, this worked, but now throws the following exception:

      groovy.lang.MissingPropertyException: No such property: p1 for class: Script1

       

      However, if I hard-code the username and password as below, there's no error:

        void process(HttpRequest httpRequest, HttpContext httpContext) {
          httpRequest.addHeader('Authorization', 'Basic ' + 'username:password'.bytes.encodeBase64().toString())

      Stack-trace is sizeable, will attach separately.

            vjuranek vjuranek
            stealthdj Tony Noble
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: