Building CMake Project with Jenkins on Windows
Jenkins is an open-source continuous integration tool. I am new to Jenkins. To get familiar with it, I decided to start learning from a CMake project written with Dynamsoft Barcode Reader.
Prerequisites
Initializing Jenkins Environment
Stop and start Jenkins
After installing Jenkins by running setup wizard, you can visit localhost:8080 to initialize the Jenkins environment. To stop Jenkins, run cmd.exe as administrator and use the command ‘net stop jenkins’. To manually run Jenkins, use command ‘net start jenkins’ or ‘java -jar Jenkins.war’.
Admin password
Login Jenkins account with the initial password which is located at ‘Jenkins\secrets\initialAdminPassword’.
Customize plugins
On the plugin selection page, you can install plugins. I needed a clean environment, and therefore I closed the page without installing any plugin.
Manage users
Click ‘Jenkins > Manage Jenkins > Manage Users > Create User’ to add a new user.
Building CMake Project
So far, the Jenkins environment is ready. Click ‘New Item’ to create a new project.
The Source Code Management is none. Don’t worry, because I didn’t install any SCM plugin. Save the configuration and jump to the project page.
Click ‘Build Now’ to generate an empty project at Jenkins\workspace\dbr.
Get the source code https://github.com/dynamsoft-dbr/cmake.git. Copy source code to the folder. In addition, copy Barcode Reader 5.2\Components\C_C++\Lib\DBRx64.lib and Barcode Reader 5.2\Components\C_C++\Redist\DynamsoftBarcodeReaderx64.dll to platforms\win folder.
Click Workspace. You can see all files are listed.
Windows batch command
Click Configure > Build to add ‘Execute Windows batch command’.
mkdir build
cd build
cmake -G"Visual Studio 14 2015 Win64" ..
cmake --build .
Save the commands and click ‘Build Now’.
I got following error message when building the project:
The system cannot find the file specified
ERROR: Cannot run program “cmake”
No idea what happened. After re-installing Jenkins, the error was gone.
CMake plugin for Jenkins
Using CMake plugin is a better way to build CMake project.
Download CMake plugin.
Click Jenkins > Manage Jenkins > Manage Plugins > Advanced to add the plugin.
Switch back to the configuration page, and we can now see the CMake build options.
Fill out the build options as follows:
Build the project to generate Jenkins\workspace\dbr\build\Release: