C++ - Qt Framework - Using Jenkins to generate an .EXE file

In this tutorial we are going to see how to download a project directly on GitHub, generate makefiles of this project, compile it and copy several dynamic-link libraries from a directory to another one.

And all that steps automatically!

Let's see this in this Jenkins setup for Qt on Windows with MinGW.

First of all

We'll use one of my project that I already put on GitHub in order to use it as an example:

You don't need to download it, Jenkins will do that for us.

My Jenkins is installed in:

  • C:\soft\jenkins

The project which be downloaded from GitHub will be installed (automatically) in:

  • C:\soft\jenkins\workspace

My Qt with version 5.8 is installed in:

  • C:\Qt

I'll use the MinGW compiler for this tutorial with the version 530_32, so if you use the Microsoft Vistual Studio compiler, just change the paths to yours.

In your Windows Environment variables, add the following line (you can change the version of your MinGW of course): 

  • C:\Qt\Tools\mingw530_32\bin

It's time now to set the Jenkins server.

Jenkins

We supposed that you already installed Jenkins, so let's continue.

From Jenkins: New Item > Enter a name (like test1) > Click Freestyle project > OK.

You are now in Configure parameters for this project.

You can see this in the URL that should be something like that: 

In the General tab, you can see the project name: test1

For the Source Code Management tab, select: Git

Then as Repository URL write: https://github.com/badprog/badprog-qt-moving-shape-1.git

In the build Triggers tab, check Build periodically and write as Schedule:

H/2 * * * *

This will launch the process every 2 minutes for ever.

For the Build Environment, check Delete workspace before build starts.

It will show us that the project will be deleted every 2 minutes if we stay in the workspace directory.

OK now let's see the Build tab, which is the most important there.

Click the Add build step drop down menu > Execute Windows batch command.

In the Command text area type the following code:

:: BadproG.com
:: =====================
:: Generating Makefile |
:: =====================

"C:/Qt/5.8/mingw53_32/bin/qmake.exe" C:/soft/jenkins/workspace/test1/badprog-qt-moving-shape-1/moving-shape-1.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"

:: ===========
:: Compiling |
:: ===========

"C:/Qt/Tools/mingw530_32/bin/mingw32-make.exe" -f C:/soft/jenkins/workspace/test1/Makefile.Debug

:: ======================================
:: Moving .dll to the project directory |
:: ======================================

copy "C:\Qt\5.8\mingw53_32\bin\Qt5Cored.dll"       C:\soft\jenkins\workspace\test1\debug\Qt5Cored.dll
copy "C:\Qt\5.8\mingw53_32\bin\Qt5Widgetsd.dll"    C:\soft\jenkins\workspace\test1\debug\Qt5Widgetsd.dll
copy "C:\Qt\5.8\mingw53_32\bin\Qt5Guid.dll"        C:\soft\jenkins\workspace\test1\debug\Qt5Guid.dll
copy "C:\Qt\5.8\mingw53_32\bin\libgcc_s_dw2-1.dll" C:\soft\jenkins\workspace\test1\debug\libgcc_s_dw2-1.dll
copy "C:\Qt\5.8\mingw53_32\bin\libstdc++-6.dll"    "C:\soft\jenkins\workspace\test1\debug\libstdc++-6.dll"

copy "C:\Qt\5.8\mingw53_32\bin\libwinpthread-1.dll"    "C:\soft\jenkins\workspace\test1\debug\libwinpthread-1.dll"

All these lines can be replaced by setting correctly your Windows System environment variables with the corresponding binaries.

But for our example I thought that letting the complete paths of each line was quite interesting to understand it better.

OK, once you've typing all these lines in the Command text area, you can save it.

Click Save.

OK, on your left, click Back to Dashboard in order to see the current job test1 in the list.

You can start it manually or wait until it starts by its own.

To launch it, click the icon on the right of the test1 job line (a clock with a green triangle).

The job should start.

You can now open your directory in order to see the project downloaded from GitHub:

  • C:\soft\jenkins\workspace\test1\debug

You should see about 15 files (if you see less than 15 files, just wait until you have them all).

Here we go, double click the moving-shape-1.exe file in order to launch the application project.

Conclusion

This Jenkins tutorial for Qt is just the beginning of Continous Integration.

Very pleasant and useful when you want to have an assistant in your compilation process.

Good job, once again you did it! cool

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.