Skip to content

Groovy hook tries to compile init scripts  #226

@alexsedova

Description

@alexsedova

Jenkins as a code setup has good numbers of groovy scripts for many different plugins configurations. However, we don't want users to install all plugins the setup is supporting. One of the option to prevent compilation during Jenkins startup is to use a def dynamic variable and whole classpath. It seems some scripts don't meet these requirements and fail during startup with a compilation error. For example, artifactory.groovy.

WARNING: Failed to run script file:/var/jenkins_home/init.groovy.d/artifactory.groovy
�[35mjmaster_1       |�[0m org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 22: unable to resolve class CredentialsConfig 
�[35mjmaster_1       |�[0m  @ line 22, column 23.
�[35mjmaster_1       |�[0m        CredentialsConfig deployerCredentials = new CredentialsConfig(getPasswordCredentials(serverConfig.deployerCredentialsId),
�[35mjmaster_1       |�[0m                          ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 22: unable to resolve class CredentialsConfig 
�[35mjmaster_1       |�[0m  @ line 22, column 45.
�[35mjmaster_1       |�[0m    sConfig deployerCredentials = new Creden
�[35mjmaster_1       |�[0m                                  ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 25: unable to resolve class CredentialsConfig 
�[35mjmaster_1       |�[0m  @ line 25, column 23.
�[35mjmaster_1       |�[0m        CredentialsConfig resolverCredentials = new CredentialsConfig(getPasswordCredentials(serverConfig.deployerCredentialsId),
�[35mjmaster_1       |�[0m                          ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 25: unable to resolve class CredentialsConfig 
�[35mjmaster_1       |�[0m  @ line 25, column 45.
�[35mjmaster_1       |�[0m    sConfig resolverCredentials = new Creden
�[35mjmaster_1       |�[0m                                  ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 28: unable to resolve class ArtifactoryServer 
�[35mjmaster_1       |�[0m  @ line 28, column 10.
�[35mjmaster_1       |�[0m        List<ArtifactoryServer> servers =  desc.getArtifactoryServers()
�[35mjmaster_1       |�[0m             ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 29: unable to resolve class ArtifactoryServer 
�[35mjmaster_1       |�[0m  @ line 29, column 23.
�[35mjmaster_1       |�[0m        ArtifactoryServer server = new ArtifactoryServer(serverConfig.serverName,
�[35mjmaster_1       |�[0m                          ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m /var/jenkins_home/init.groovy.d/artifactory.groovy: 29: unable to resolve class ArtifactoryServer 
�[35mjmaster_1       |�[0m  @ line 29, column 32.
�[35mjmaster_1       |�[0m        ArtifactoryServer server = new ArtifactoryServer(serverConfig.serverName,
�[35mjmaster_1       |�[0m                                   ^
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m 7 errors
�[35mjmaster_1       |�[0m 
�[35mjmaster_1       |�[0m 	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
�[35mjmaster_1       |�[0m 	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:946)
�[35mjmaster_1       |�[0m 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
�[35mjmaster_1       |�[0m 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
�[35mjmaster_1       |�[0m 	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
�[35mjmaster_1       |�[0m 	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
�[35mjmaster_1       |�[0m 	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
�[35mjmaster_1       |�[0m 	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
�[35mjmaster_1       |�[0m 	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:584)
�[35mjmaster_1       |�[0m 	at jenkins.util.groovy.GroovyHookScript.execute(GroovyHookScript.java:136)
�[35mjmaster_1       |�[0m 	at jenkins.util.groovy.GroovyHookScript.execute(GroovyHookScript.java:127)
�[35mjmaster_1       |�[0m 	at jenkins.util.groovy.GroovyHookScript.run(GroovyHookScript.java:110)
�[35mjmaster_1       |�[0m 	at hudson.init.impl.GroovyInitScript.init(GroovyInitScript.java:41)
�[35mjmaster_1       |�[0m 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
�[35mjmaster_1       |�[0m 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
�[35mjmaster_1       |�[0m 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
�[35mjmaster_1       |�[0m 	at java.lang.reflect.Method.invoke(Method.java:498)
�[35mjmaster_1       |�[0m 	at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
�[35mjmaster_1       |�[0m 	at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
�[35mjmaster_1       |�[0m 	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
�[35mjmaster_1       |�[0m 	at jenkins.model.Jenkins$7.runTask(Jenkins.java:1089)
�[35mjmaster_1       |�[0m 	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
�[35mjmaster_1       |�[0m 	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
�[35mjmaster_1       |�[0m 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
�[35mjmaster_1       |�[0m 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
�[35mjmaster_1       |�[0m 	at java.lang.Thread.run(Thread.java:745)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions