Hi,
I want to provide a clear series of steps to reproduce this bug because as I was reproducing it, I ran into a another possibly related problem. I use Jenkins 1.532.3. The steps to reproduce are:
Install Jenkins with the Groovy Postbuild plugin, restart Jenkins
I have downloaded jenkins.war to my ~/Downloads folder on linux (this is important, see below).
Create a freestyle job
Add a build step: Execute shell
Set the content of the shell to:
#!/bin/bash
# wipe out the workspace
rm -rf *
# Create a groovy script for postbuild
mkdir -p subfolder
printf "class PostBuild {
def manager
def PostBuild(manager) {
this.manager = manager
}
def run() {
println('Done')
}
}
" >subfolder/PostBuild.groovy
Add a Post-build action or type "Groovy Postbuild"
Set the Groovy script to:
import PostBuild
def postBuild = new PostBuild(manager)
postBuild.run()
Set the additional groovy classpath to: $WORKSPACE/subfolder
Save the job, and run it.
The job will fail to resolve the class PostBuild because the $WORKSPACE variable is not expanded.
Additional details
Now go back and edit the job configuration again. Examine the value of the classpath again: Jenkins has changed it to /home/username/Downloads/$WORKSPACE/subfolder. This is rather unexpected. Is this because jenkins.war was installed in /home/username/Downloads? I think the classpath should not be modified by the plugin.
So I think this issue consists of is one bug and one feature request:
- Feature request: The $WORKSPACE variable should be expanded
- Bug: Jenkins re-writes the additional groovy classpath to /home/username/Downloads/$WORKSPACE/subfolder, but it should leave the classpath alone after it has been set by the user.
Lastly, the plugin does not support multiple colon separated classpath values. When I move the PostBuid.groovy script to say /home/username/groovyLib, and I set the classpath to /home/username/groovyLib:/home/username/otherLib then the plugin is unable to evaluate the groovy script. If the plugin was intended to support multiple classpath values, then this is also a bug.