Setters for shared pipeline scripts not getting called

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      According to the Jenkins docs, one should be able to define getters and setters for global variables in shared pipeline scripts to manipulating fields. This does not seem to work correctly. Take the following example which is a slight variation on the example from the docs:

       

      // tmp_shared/vars/acme.groovy
      def setName(value) {
          echo "Setting name to $value"
          this.@name = value
      }
      def getName() {
          echo "Getting name of " + this.@name
          return this.@name
      }
      
      // Pipeline script
      @Library ('tmp_shared') _
      
      acme.name = 'Alice'  // should print "Setting name to Alice" to the console
      def tmp = acme.name  // should print "Getting name of Alice" to the console

      I'd expect the output from this simple test to look something like this:

      ...
      Setting name to Alice
      Getting name of Alice
      ...

      However I see no console output whatsoever. This indicates that the getter and setter methods are not being invoked at all when defined in the Groovy vars scripts for a shared pipeline library. 

       

            Assignee:
            Unassigned
            Reporter:
            Kevin Phillips
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: