While working on a Qt project for Symbian OS, I decided to try the Jenkins continuous integration server to automate local builds and just get acquainted with the system. At that point I wanted to set up a build process to get a
.sis file ready to be installed on a device.
Looking around the internets about hooking up qmake (Qt’s build system) and Jenkins, I found one plugin — qmakebuilder on the Jenkins website, but it wasn’t available for installation from within the server itself. Apparently, it’s not maintainable anymore. So, I chose the second way, which is to use shell/batch files. In order to build a
.sis package symbian toolchain is used, which is only supported on windows, so there is no choice there.
Let’s kick it off.
In Qt Creator I create a new project (Mobile Qt Application) named
TestProject, and obviously use git for it.
Build, run, check it runs in the simulator. OK, install Jenkins. Before adding a project, Jenkins needs to know where git is in the system. I use portablegit on Windows. Go to Manage Jenkins / Configure System / Git installations / Path to Git executable:
Now, create a new project in Jenkins. Project option: Build a free-style software project. Name:
In Git section set Repository URL to path where your project is:
file:///c:/qt_test/TestProject/. Branches to build:
Next, Build Triggers section. Poll SCM option will check your project repository once in a while, and build when changes have been found. For the beginning, set Schedule to poll the repo at 20th minute of every hour:
20 * * * *.
Here, on my computer, I needed to change the directory where builds occur, because the QtSDK had been installed in C: drive, whereas the Jenkins had been set up in D:. Symbian toolchain doesn’t support building projects located on drives different from the one where itself is installed. Therefore, I asked Jenkins to build the project in the same C: drive by going to Advanced Project Options / Use custom workspace:
Running Build now at this point should give a clone of your project repository in the specified jenkins workspace directory:
1 2 3 4 5 6 7 8 9 10 11 12
Now the main thing, configuring the commands to run a build. In the toolchain there is a batch file that prepares the environment before you could build a Qt symbian project from the terminal. The path is
\QtSDK\Symbian\SDKs\Symbian1Qt473\bin\qtenvS1.bat. Unfortunately, the last command in the file runs another shell, and that’s what we don’t want here. (If you’re wondering, running
qtenvS1.bat directly outputs this:
1 2 3 4
Great success, really?).
So, my solution is the following: copy the file
qtenvS1_.bat, in which remove the last line (with cmd command). Then go to project settings / Build section / Add build step / Execute Windows batch command. The magic command is the following:
1 2 3 4 5 6 7
The first part saves the current directory (the one where the project is being built), sets up the environment, and jumps back to the saved directory.
The second part is taken from the project’s Build Settings in Qt Creator. It builds the project in release mode and then creates a sis package with the app.
Build now, wait for a while (some more information about that: link),
, and you’ll find a sis package on completion. You can also archive the file so that it may be downloaded from the Jenkins webpage later. Go to Post-build Actions / Archive the artifacts / Files to Archive:
Once I’ve set up the system, I realized how convenient it is indeed. Every hour I can have a release build for testing or client. Of course, this step in only introduction to CI systems.
I believe this description may seem cumbersome and/or vague, so if you have any questions, don’t hesitate to leave a comment.