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

groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: script

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • workflow-cps-plugin
    • None

      groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: script for class: my.lib.MyClass
      

      This error is thrown when running (MyClass is loaded from a shared library):

      @Library("my-lib") _
      new my.lib.MyClass(this)
      

      MyClass:

      package my.lib
      
      class MyClass implements Serializable {
      
          final protected script
      
          MyClass(script) {
              this.script = script
          }
      }
      

      Is this expected? Disabling the sandbox the problem goes away.

          [JENKINS-45824] groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: script

          Antonio Muñiz created issue -
          Antonio Muñiz made changes -
          Description Original: {code}
          groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: script for class: my.lib.MyClass
          {code}

          This error is thrown when running (MyClass is loaded from a shared library):

          {code}
          @Library("my-lib") _
          new my.lib.MyClass(this)
          {code}

          MyClass:
          {code}
          package my.lib

          class MyClass implements Serializable {

              final protected script

              MyClass(script) {
                  this.script = script
              }
          }
          {code}

          Is this expected?
          New: {code}
          groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: script for class: my.lib.MyClass
          {code}

          This error is thrown when running (MyClass is loaded from a shared library):

          {code}
          @Library("my-lib") _
          new my.lib.MyClass(this)
          {code}

          MyClass:
          {code}
          package my.lib

          class MyClass implements Serializable {

              final protected script

              MyClass(script) {
                  this.script = script
              }
          }
          {code}

          Is this expected? Disabling the sandbox the problem goes away.
          Andrew Bayer made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Component/s Original: pipeline [ 21692 ]

            Unassigned Unassigned
            amuniz Antonio Muñiz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: