Skip to content

Tarik-B/test_ci_cd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins build pipeline template for C++ project

Features
Jenkins pipeline overview
Setup
Usage
Todo
Credits

Features

  • CMake-based Qt6/C++17 project
  • Semantic Versioning (version.txt)
  • Cross-compilation (x64 Linux and Windows via MinGW-w64), multi-configurations (debug and release) builds
  • Static analysis and runtime memory check
  • Unit and functional testing
  • Dockerized builds
  • Git pre-commit hook
  • GitHub hook build triggers (via smee.io)
  • Desktop notifications (just use CatLight)

Jenkins pipeline overview

  1. Buildsystem generation (CMake)
  2. Static code analysis (Cppcheck)
  3. Build (g++)
  4. Sanity check (Valgrind's memcheck)
  5. Unit tests and coverage (CTest)
  6. Functional tests (Robot Framework)
  7. Artifacts packaging

Setup

All commands/scripts must be run from repository's root directory.

Requirements

  • Linux
  • Jenkins
  • Docker (optional, for dockerized builds)
  • g++, CMake
  • MinGW-w64 + runtime environment for gcc and Wine64
  • Cppcheck, Valgrind, Clang-Tidy (for analysis)
  • Python3, pip and venv module (for Robot Framework)

See docker/Dockerfile for a complete list of required packages (Debian-based distros).

Jenkins plugins used

Docker setup

  • Build (builds Qt from sources and setups build environment):
$ docker build --progress=plain -t tarikbelabbas/jenkins_agent -f docker/Dockerfile .
  • Test (interactive shell):
$ docker run -it --mount type=bind,source=${PWD},target=/home/jenkins/test_ci_cd --rm tarikbelabbas/jenkins_agent bash
  • Cleanup:
$ docker system prune -a -f
$ docker builder prune

Usage

Pipeline script (for manual builds)

  • Linux build:
$ scripts/pipeline.sh --platform linux --build-type debug --qt-target-path /home/jenkins/qt_install_linux/ all
  • Windows (cross-compilation) build:
$ scripts/pipeline.sh --platform windows --build-type debug --qt-target-path /home/jenkins/qt_install_windows/ --qt-host-path /home/jenkins/qt_install_linux/ all

Other scripts

  • Install Git pre-commit hook:
$ scripts/install_pre_commit_hook.sh
  • Transfer GitHub webhooks via smee to local Jenkins (port 8080):
$ scripts/smee.sh <smee-id>

Todo

  • update-binfmts not working
  • windows dynamic linking/library search path/windeployqt shenanigans
  • max warning + warnings as error
  • use clang
  • other static analyzers: clang-tidy, clazy (qt-oriented analyzer)
  • code formatting: clang-format, cpplint
  • dependency (like catch2) management via conan?
  • separate debug symbols? (+ generate symbols in release too)
  • JCasC (Jenkins Configuration as Code)?
  • git checkout only once (for both debug and release)
  • track and monitor build times
  • check if plugins exists (robot, etc.) before using them in jenkins pipeline?
  • performance analysis and tracking
  • refactor scripts/install.sh into a --install pipeline option
  • add port argument to smee script
  • c++ 20/23

Credits

About

Jenkins build pipeline template for C++ project

Topics

Resources

License

Stars

Watchers

Forks

Contributors