The first versions of the cmake builder plugin were developed more or less only driven by our own needs. As people began to use it an issue came up that we hadn’t considered yet: distributed builds, a.k.a master/slave mode. So on our first OSLD in 2010 I looked into the plugin and began to rectify the situation.
My test setup consisted of a hudson master on WindowsXP box which was connected via SSH to a slave node in a Ubuntu virtual machine. The first errors were easy to find. The plugin tried to find all configured paths on the windows host and not on the ubuntu slave.
Experience from our previous Crap4J plugin development and a quick read here brought me on the right track. It’s not a good idea to use just java.io.File if you want your plugin to be master/slave capable – use hudson.FilePath instead.
So after replacing all java.io.File occurrences with hudson.FilePath the situation was much better. The plugin handled all paths correctly but still produced errors when calling cmake. I quickly discovered that java.lang.Process and java.lang.ProcessBuilder were used to call “cmake -version”. Again, not a good idea – hudson.Launcher is your friend here.
After replacing Process with Launcher I had only one strange error left. The following launcher call using a nice fluent interface wouldn’t execute on the remote machine but insisted to execute locally.
launcher.launch().cmds(cmakeCall).envs(environmentVars) .stdout(listener).pwd(workDir).join();
When I changed it to the seemingly equal statement
launcher.launch(cmakeCall, environmentVars, listener.getLogger(), workDir).join();
it worked like a charm.
After all those changes I proudly present the newest version of CMake Builder Plugin which is now ready to be used in distributed environments.
Only one little unpleasantness still exists, though: when configuring the make and install commands the plugin tries to find the executables on the PATH of host machine. For now, you can just ignore the error message. I try to look into it, soon. Apart from that, have fun with the new version.
Many thanks for this, works perfectly with a Windows master running OSX and Linux slaves.
One minor unrelated issue I spotted: When configuring a project the dropdown menu for build type doesn’t remember the previously stored value, causing me to sometimes accidentally switch back to Debug build type.