Accessing a Jenkins plugin package from a Groovy script

groovy, jenkins

Solution

In Postbuild Groovy script you can specify Additional groovy classpath. For example: `/var/jenkins/plugins/claim/WEB-INF/classes` for Claim plugin code. I tried it and it worked.

Unfortunately the path has to be absolute and does not allow for environment variables (such as `${JENKINS_HOME}`). Also, I am not entirely sure where the script will look when run on a slave - on the slave or on master.

Problem

How can I find the path to a Jenkins plugin if I want to use it from a groovy script? For example, just testing on the master, I'd like to be able to use the LabelParameterValue class from the NodeLabelParameter plugin. An example of what I'm looking for is below, (though it doesn't work). `currentParameters.add(new hudson.plugins.nodelabelparameter.LabelParameterValue(nodeName))`

Original source