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. getenv-PATH.groovy
          0.0 kB
        2. import-lockable-resources-manager.groovy
          0.2 kB
        3. plugins.txt
          2 kB
        4. run-jenkins.sh
          0.9 kB
        5. scriptApproval.xml
          1 kB
        6. scriptler.xml
          0.9 kB

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

          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 added a comment -

          I'm able to duplicate the issue and I believe there is a workaround. Instead of using scriptler plugin 393.vc44e60d60fa_1 or scriptler 384.387.vb_5cb_a_f774857, use scriptler plugin 376.v152edd95b_ca_f.

          I could duplicate the problem with Jenkins 2.479.2 and scriptler plugin 384.387.vb_5cb_a_f774857. I could duplicate the problem with Jenkins 2.492 and scriptler plugin 393.vc44e60d60fa_1.

          Steps that I took to duplicate the problem with Jenkins 2.479.2 and scriptler plugin 384.387.vb_5cb_a_f774857:

          1. Create a plugins.txt file that lists precise plugins and their versions
          2. Create a run-jenkins.sh shell script that downloads Jenkins 2.479.2 and the listed plugins and runs them
          3. Create a scriptApproval.xml file that lists script approvals
          4. Create scriptler/ scriptler.xml that defines the scriptler settings
          5. Create scriptler/scripts/ getenv-PATH.groovy with the sample script
          6. Create scriptler/scripts/ import-lockable-resources-manager.groovy with a simple use of lockable resources import
          7. Run the run-jenkins.sh shell script and complete the setup wizard by creating a new user and installing no additional plugins
          8. Run the scriptler sample script getenv-PATH and confirm that it works
          9. Run the scriptler import-lockable-resources-manager script and confirm that it fails to import

          If the same steps are used and the scripter plugin 376.v152edd95b_ca_f is used, it works.

          mtughan I think this indicates a bug in newer versions of the scriptler plugin.

          Mark Waite added a comment - I'm able to duplicate the issue and I believe there is a workaround. Instead of using scriptler plugin 393.vc44e60d60fa_1 or scriptler 384.387.vb_5cb_a_f774857, use scriptler plugin 376.v152edd95b_ca_f. I could duplicate the problem with Jenkins 2.479.2 and scriptler plugin 384.387.vb_5cb_a_f774857. I could duplicate the problem with Jenkins 2.492 and scriptler plugin 393.vc44e60d60fa_1. Steps that I took to duplicate the problem with Jenkins 2.479.2 and scriptler plugin 384.387.vb_5cb_a_f774857: Create a plugins.txt file that lists precise plugins and their versions Create a run-jenkins.sh shell script that downloads Jenkins 2.479.2 and the listed plugins and runs them Create a scriptApproval.xml file that lists script approvals Create scriptler/ scriptler.xml that defines the scriptler settings Create scriptler/scripts/ getenv-PATH.groovy with the sample script Create scriptler/scripts/ import-lockable-resources-manager.groovy with a simple use of lockable resources import Run the run-jenkins.sh shell script and complete the setup wizard by creating a new user and installing no additional plugins Run the scriptler sample script getenv-PATH and confirm that it works Run the scriptler import-lockable-resources-manager script and confirm that it fails to import If the same steps are used and the scripter plugin 376.v152edd95b_ca_f is used, it works. mtughan I think this indicates a bug in newer versions of the scriptler plugin.

          Basil Crow added a comment -

          Basil Crow added a comment - Reverting https://github.com/jenkinsci/scriptler-plugin/pull/67 as in https://github.com/jenkinsci/scriptler-plugin/pull/139 resolves the issue for me.

          This should be resolved now. Released as 397.vc46f19cb_3c18 for the latest weekly releases and 384.388.v7e1d47fc65f4 for supporting the 2.479.x LTS releases.

          Michael Tughan added a comment - This should be resolved now. Released as 397.vc46f19cb_3c18 for the latest weekly releases and 384.388.v7e1d47fc65f4 for supporting the 2.479.x LTS releases.

          Charles added a comment -

          Thanks a bunch mtughan 

          Charles added a comment - Thanks a bunch mtughan  

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

              Created:
              Updated:
              Resolved: