A few months ago I set out to build my first hudson plugin. It was an interesting, sometimes difficult journey which came to a good end with the CMake Builder Plugin, a build tool which can be used to build cmake projects with hudson. The feature set of this first version was somewhat limited since I applied the scratch-my-own-itch approach – which by the time meant only support for GNU Make under Linux.
As expected, it wasn’t long until feature requests and enhancement suggestions came up in the comments of my corresponding blog post. So in order to make the plugin more widely useable I used our second Open Source Love Day to add some nice little features.
Let’s take a walk through the configuration of version 1.0:

1. As in the first version you have to set the path to the cmake executable if it’s not already in the current PATH.
2. The build configuration starts as in the first version with Source Directory, Build Directory and Install Directory.

3. The Build Type can now be selected more conveniently by a combo box.
4. If Clean Build is checked, the Build Dir gets deleted on every build

5. The advanced configuration part starts with Makefile Generator parameter which can be used to utilize the corresponding cmake feature.
6. The next two parameters Make Command and Install Command can be used if make tools other than GNU Make should be used
7. Parameter Preload Script can be used to point to a suitable cmake pre-load script file. This gets added to the cmake call as parameter of the -C switch.
8. Other CMake Arguments can be used to set arbitrary additional cmake parameters.
The cmake call will then be build like this:
/path/to/cmake \ -C </path/to/preload/script/if/given \ -G <Makefile Generator> \ -DCMAKE_INSTALL_PREFIX=<Install Dir> \ -DCMAKE_BUILD_TYPE=<Build Type> \ <Other CMake Args> \ <Source Dir>
After that, the given Make and Install Commands are used to build and install the project.
With all these new configuration elements, the CMake Builder Plugin should now be applicable in nearly every project context. If it is still not useable in your particular setting, please let me know. Needless to say, feedback of any kind is always appreciated.
December 20, 2009 at 7:50 pm |
Hey,
I have trouble using this hudson plugin with git. I have tried both the hudson mailing list and the irc channel, without success. Maybe you can help me:
I have a simple hudson job, checking out a local git repository and supposedly building it with your CMake plugin. It fails and the output is:
Checkout:workspace / /var/lib/hudson/jobs/build-helloworld/workspace – hudson.remoting.LocalChannel@1f5b38e
Last Build : #19
Last Built Revision: Revision b6b13ae02c124d97c9266ee40e0144d96ff84c52 (origin/master )
Checkout:workspace / /var/lib/hudson/jobs/build-helloworld/workspace – hudson.remoting.LocalChannel@1f5b38e
Cloning the remote Git repository
Cloning repository origin
$ /usr/bin/git clone -o origin /var/git/helloworld.git/ /var/lib/hudson/jobs/build-helloworld/workspace
Fetching upstream changes from /var/git/helloworld.git/
[workspace] $ /usr/bin/git fetch /var/git/helloworld.git/ +refs/heads/*:refs/remotes/origin/*
[workspace] $ /usr/bin/git ls-tree HEAD
Seen branch in repository origin/master
Commencing build of Revision b6b13ae02c124d97c9266ee40e0144d96ff84c52 (origin/master )
Checking out Revision b6b13ae02c124d97c9266ee40e0144d96ff84c52 (origin/master )
[workspace] $ /usr/bin/git checkout -f b6b13ae02c124d97c9266ee40e0144d96ff84c52
[workspace] $ /usr/bin/git tag -a -f -m “Hudson Build #20″ hudson-build-helloworld-20
Recording changes in branch origin/master
[workspace] $ /usr/bin/git log –numstat -M –summary –pretty=raw b6b13ae02c124d97c9266ee40e0144d96ff84c52..b6b13ae02c124d97c9266ee40e0144d96ff84c52
MODULE: /var/lib/hudson/jobs/build-helloworld/workspace
Build dir : /var/lib/hudson/jobs/build-helloworld/workspace/build
CMake call : /usr/bin/cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=/var/lib/hudson/jobs/build-helloworld/workspace -DCMAKE_BUILD_TYPE=Debug “/var/lib/hudson/jobs/build-helloworld/workspace/source”
[build] $ /usr/bin/cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=/var/lib/hudson/jobs/build-helloworld/workspace -DCMAKE_BUILD_TYPE=Debug /var/lib/hudson/jobs/build-helloworld/workspace/source
Finished: FAILURE
I first tried to make sure that git is working correctly, so instead of building CMake, I setup a shell command running doxygen – that works just fine. Next I tried to verify that my CMake files are setup correctly, and did the following: I cloned the git repository manually in my user folder using
$ git clone /var/git/helloworld.git/ workspace
I then fixed permissions such that hudson has read write access to the folder workspace. In hudson, I setup the build task entering /path/to/workspace/source as “source folder” (as there is a folder called source in my git repo) and /path/to/workspace/build as my “build directory”. I cleared the field “install directory” as I do not want to install and in advanced options cleared the field “install command”. I then ran the task and it worked. I double checked the folder, the Makefile and the executable were generated correctly.
So it seems as if both the git plugin and the cmake plugin in itself work fine, but not in combination with each other, and the above console log does not give me any clues on whats going wrong. The workspace folder is also always empty when I check it (is that the normal behavior?)
Any ideas on what I am missing here?
December 20, 2009 at 9:28 pm |
Okay, the problem seems to be that the cmake plugin needs the install command, and I did not have any install config in my CMakeLists.txt. I have it up and running now.
December 21, 2009 at 9:52 am |
Thanks for your feedback! You’re right, “Finished: FAILURE” is not really chatty
The next version will have some more meaningful error message.
December 22, 2009 at 2:48 pm |
I tried to setup a situation where error messge “Finished: FAILURE” is the only output when trying run a build. Seems that this happens only when “cmake” cannot be executed (e.g. beacuse it’s not in PATH). So I added a check for the cmake executable to the plugin. Check out version 1.1.
BTW, everything went fine when I removed the install command and the install config from my CMakeLists.txt, so there must have been another reason for your problems.
December 25, 2009 at 12:22 am |
Thank you for creating CMakeBuilder.
Has anyone tried this on a master/slave system? I have a Unbuntu master and a OS X slave. During my first runs, I got:
Started by user anonymous
Building remotely on macmini
Updating svn://192.168.11.3/dev/cpp/afengine
At revision 626
no change for svn://192.168.11.3/dev/cpp/afengine since the previous build
MODULE: /Users/hudson/workspace/afengine/.
Cleaning Build Dir… /Users/hudson/workspace/afengine/bld
Directory could not be created: /Users/hudson/workspace/afengine/bld
Finished: FAILURE
———————————-
I thought the Directory could not be created error was caused by user permissions. svn was able to check out the entire path tree okay as user Hudson on the OS X slave. I tried many things on the OS X slave including chmod a+rw on the path down the tree and even creating the bld directory by hand. Nothing worked.
However, when I create entire tree on the Ubuntu master, I started getting a different error message:
Started by user anonymous
Building remotely on macmini
Updating svn://192.168.11.3/dev/cpp/afengine
At revision 626
no change for svn://192.168.11.3/dev/cpp/afengine since the previous build
MODULE: /Users/hudson/workspace/afengine/.
Cleaning Build Dir… /Users/hudson/workspace/afengine/bld
/Users/hudson/workspace/afengine/src
Finished: FAILURE
———————————-
which is fine, because I didn’t create that directory on the Ubuntu master. I browsed the open source code down to line 33 in CmakeBuilderImpl.java, where the IOException() was thrown, but I don’t know enough about Hudson plugins and the conventions for ensuring that the code is executed on the slave and not on the master.
I hope I am not chasing this problem down the wrong path. If anyone has any suggestions and/or work-arounds, please do post. Thank you.
- Ken
January 18, 2010 at 3:08 am |
Just to say that i’ve had the same problem as Ken: “Directory could not be created”. I’ve also double checked permission on the slave, tried to create the builddir myself… but i was not able to find any way of making it work.