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

Impossible to import plugin classes in scripts since upgrade to Java 17

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • scriptler-plugin
    • None

      My team is running a Dockerized deployment of Jenkins. Recently, we have been trying to go from Jenkins version 2.462.2 to 2.489, and scriptler from version 376.v152edd95b_ca_f to 393.vc44e60d60fa_1.

      We have bunch of Scriptler scripts we use to sync configuration defined declaratively in our instance without restart. We used to be able to import classes from other installed plugins in the scripts, for example org.jenkins.plugins.lockableresources.LockableResource , CloudBees folder classes, etc.

      Now importing them results in compilation errors.

      Script1.groovy: 19: unable to resolve class org.jenkins.plugins.lockableresources.LockableResourcesManager @ line 19, column 1. import org.jenkins.plugins.lockableresources.LockableResourcesManager

      I have verified and running the same script from the script console works just fine. It also worked fine before the update. We use Scriptler mainly because we can run the scripts on the built-in node of the controller, since they modify internal Jenkins config, but we don't want regular jobs running there, so it's explicitly configured to have 0 executors. Is there something that changed recently in the way classes are loaded into the scripts that is preventing the plugins to be discoverable ?

        1. import-lockable-resources-manager.groovy
          0.2 kB
        2. getenv-PATH.groovy
          0.0 kB
        3. scriptler.xml
          0.9 kB
        4. scriptApproval.xml
          1 kB
        5. run-jenkins.sh
          0.9 kB
        6. plugins.txt
          2 kB

          [JENKINS-75019] Impossible to import plugin classes in scripts since upgrade to Java 17

          Charles created issue -
          Charles made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Charles made changes -
          Description Original: My team is running a Dockerized deployment of Jenkins. Recently, we have been trying to go from Jenkins version 2.462.2 to 2.489, and scriptler from version 376.v152edd95b_ca_f to 393.vc44e60d60fa_1.

          We have bunch of Scriptler scripts we use to sync configuration defined declaratively in our instance without restart. We used to be able to import classes from other installed plugins in the scripts, for example {{org.jenkins.plugins.lockableresources.LockableResource}} , CloudBees folder classes, etc.

          Now importing them results in compilation errors.

          {{{}Script1.groovy: 19: unable to resolve class org.jenkins.plugins.lockableresources.LockableResourcesManager @ line 19, column 1. import org.jenkins.plugins.lockableresources.LockableResourcesManager

          {}}}I have verified and running the same script from the script console works just fine. It also worked fine before the update. We use Scriptler mainly because we can run the scripts on the built-in node of the controller, since they modify internal Jenkins config, but we don't want regular jobs running there, so it's explicitly configured to have 0 executors. Is there something that changed recently in the way classes are loaded into the scripts that is preventing the plugins to be discoverable ? {{
          }}
          New: My team is running a Dockerized deployment of Jenkins. Recently, we have been trying to go from Jenkins version 2.462.2 to 2.489, and scriptler from version 376.v152edd95b_ca_f to 393.vc44e60d60fa_1.

          We have bunch of Scriptler scripts we use to sync configuration defined declaratively in our instance without restart. We used to be able to import classes from other installed plugins in the scripts, for example {{org.jenkins.plugins.lockableresources.LockableResource}} , CloudBees folder classes, etc.

          Now importing them results in compilation errors.

          {{Script1.groovy: 19: unable to resolve class org.jenkins.plugins.lockableresources.LockableResourcesManager @ line 19, column 1. import org.jenkins.plugins.lockableresources.LockableResourcesManager}}

          I have verified and running the same script from the script console works just fine. It also worked fine before the update. We use Scriptler mainly because we can run the scripts on the built-in node of the controller, since they modify internal Jenkins config, but we don't want regular jobs running there, so it's explicitly configured to have 0 executors. Is there something that changed recently in the way classes are loaded into the scripts that is preventing the plugins to be discoverable ?

          Dmytro Lyakh added a comment - - edited

          Hi ccoupaljette_goto ,
          Did you find any solution for that?
          Experiencing the same issue.
          Not only can't the plugin classes be imported, but can't be used without importing as well,
          like trying to make a call like this 

          com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl, jenkins.model.Jenkins.instance)
          

          leads to the error message

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

          while before the update the same worked and is still working if called in the "script console"

          Dmytro Lyakh added a comment - - edited Hi ccoupaljette_goto , Did you find any solution for that? Experiencing the same issue. Not only can't the plugin classes be imported, but can't be used without importing as well, like trying to make a call like this  com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl, jenkins.model.Jenkins.instance) leads to the error message groovy.lang.MissingPropertyException: No such property: com for class: Script1 while before the update the same worked and is still working if called in the "script console"

          Andrei added a comment -

          Hello, the same issue with import for me.

          Andrei added a comment - Hello, the same issue with import for me.

          Charles added a comment -

          Hi dliakh ! I did not find a solution to the problem unfortunately. I tried using the Groovy classloader to load the classes directly for the extension jar file, but the scripts failed silently. This is still a blocking issue for my team to upgrade Jenkins because we have critical automation that depends on the plugin's ability to import other plugin's classes.

          Charles added a comment - Hi dliakh ! I did not find a solution to the problem unfortunately. I tried using the Groovy classloader to load the classes directly for the extension jar file, but the scripts failed silently. This is still a blocking issue for my team to upgrade Jenkins because we have critical automation that depends on the plugin's ability to import other plugin's classes.

          Vincent added a comment -

          Hello, I'm experiencing the same issue.

          Vincent added a comment - Hello, I'm experiencing the same issue.

          Alok added a comment -

          Any idea when this can be resolved? Also having this issue and this is a major pain for my team.

          Alok added a comment - Any idea when this can be resolved? Also having this issue and this is a major pain for my team.
          Mark Waite made changes -
          Attachment New: plugins.txt [ 63774 ]
          Mark Waite made changes -
          Attachment New: run-jenkins.sh [ 63775 ]

            mtughan Michael Tughan
            ccoupaljette_goto Charles
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: