reset Jenkins file

This commit is contained in:
berrux-dev committed 2026-10-15 20:43:46 +02:00
1 parent 26f702b7a4
commit 0e2100f383
8 files changed
+1630

No files matched your search

@@ -0,0 +1,34 @@
// Entry point of the release pipeline for the Qt6-migrated legatus
// validation-scope branch (story/release-validation-scope).
//
// Lives in jenkins-ci-rme/ of the DLBO Qt6 repo. Declares the job properties,
// allocates the build node, checks out the repo with its submodules and
// loads the build body from jenkins-ci-rme/jenkins/Jenkinsfile.
properties([
disableConcurrentBuilds(),
parameters([
choice(name: 'ProjectName', choices: ['guez'], description: 'LTS project flavor (passed to make_rpm_ubuntu26.py --project_name)'),
string(name: 'OsVersions', defaultValue: '26.04', description: 'Comma-separated Ubuntu base versions, built sequentially'),
string(name: 'LtsVersion', defaultValue: '1.0', description: 'LTS version (major.minor) passed to make_rpm_ubuntu26.py --version'),
booleanParam(name: 'ClearWorkspace', defaultValue: false, description: 'Clear entire workspace used for build'),
booleanParam(name: 'PublishArtifactRepo', defaultValue: true, description: 'Upload produced DEBs to the internal artifact repository'),
booleanParam(name: 'RunCoverage', defaultValue: true, description: 'Build the release scope with -O0 --coverage, run ctest, collect the lcov report and archive it')
])
])
node('jenkins-linux-node-2.sl.defence-elec.de') {
stage('Init submodule') {
if (params.ClearWorkspace) {
cleanWs()
}
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false]],
userRemoteConfigs: scm.userRemoteConfigs
])
}
load 'jenkins-ci-rme/jenkins/Jenkinsfile'
}
@@ -0,0 +1,54 @@
# jenkins-ci-rme — release pipeline for the Qt6 validation-scope branch
In-tree copy of the Jenkins CI flow, adapted so the release pipeline depends
only on files inside this source tree:
| File | Purpose |
|---|---|
| `Jenkinsfile` | Jenkins entry point (job script path `jenkins-ci-rme/Jenkinsfile`): job properties/parameters, build node, checkout with submodules, then `load`s `jenkins-ci-rme/jenkins/Jenkinsfile` |
| `jenkins/Jenkinsfile` | Build body (per OS version, sequentially): install the prebuilt image from `legatus-qt6_1.0.tar.gz` when missing, run the builder inside the container, coverage, publish the DEBs to the artifact repo |
| `jenkins_builder_ubuntu26.sh` | Runs **inside** the build container: stages the workspace, runs the in-tree `rpmbuild/make_rpm_ubuntu26.py`, copies the DEBs to the packages-out mount |
| `jenkins_publisher_ubuntu26.sh` | Runs on the Jenkins agent: uploads the DEBs from `${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/` to the internal artifact repository |
| `release-16-10-2026.sh` | Local driver: the same flow without Jenkins, through the in-tree `new_docker_build.sh` |
## Not included (superseded)
- `jenkins_builder.sh` / `jenkins_publisher.sh` — openSUSE/RPM flow, not used
by this branch (DEB/Ubuntu 26.04 only)
- `Dockerfile-15.1` / `Dockerfile-ubuntu26.04` / `Dockerfile-ubuntu26-qt6` —
old image recipes; the prebuilt build image is built from the in-tree
`Dockerfile` (one level up)
- `jenkins_notifier.sh` — Bitbucket build-status notification, not part of
this project
## Adaptations vs. the outer-repo copy
- Packaging uses the **in-tree** `rpmbuild/make_rpm_ubuntu26.py`
(was `${WORKSPACE}/rpmbuild` from the outer repo)
- The prebuilt build image `legatus-qt6:1.0` ships in the repo as
`legatus-qt6_1.0.tar.gz` (repo root); Jenkins `docker load`s it only when
the image is not installed on the agent yet, and never builds it
- `MIGRATE_PIPELINE_ROOT` is no longer needed: `new_docker_build.sh`
derives it from its own location
- DEB output path: `${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/` (Jenkins
convention); the packages-out copy is skipped when that directory is the
make_rpm output dir (same device:inode guard as in `new_docker_build.sh`)
- Publisher uploads `${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/` directly —
`make_rpm_ubuntu26.py` writes the DEBs there without a TDS subfolder
- The post-publish Cleanup stage was dropped: the DEBs are kept under
`${WORKSPACE}/rpms/...` (the documented output location)
## Local run
```bash
cd "DLBO Qt6"
bash ./jenkins-ci-rme/release-16-10-2026.sh
# DEBs: <repo-root>/rpms/guez/26.04/
```
## Jenkins setup
The job SCM is the DLBO Qt6 repository; the script path is
`jenkins-ci-rme/Jenkinsfile`, which loads `jenkins-ci-rme/jenkins/Jenkinsfile`.
Required Jenkins credential: `internal-repo-uploader` (username/password for
the artifact repository).
@@ -0,0 +1,135 @@
// Build body of the release pipeline for the Qt6-migrated legatus
// validation-scope branch (story/release-validation-scope): TetraIF, Z,
// Lts/Common (+ Lts/Proxies/TrainingAreaBase) -> 5 release DEB packages.
//
// Loaded by jenkins-ci-rme/Jenkinsfile inside the allocated node after the
// checkout; job properties/parameters live there.
//
// Workspace layout (checked out by Jenkins, DLBO Qt6 repo):
// <WORKSPACE>/
// jenkins-ci-rme/Jenkinsfile (entry point)
// new_docker_build.sh (local build driver)
// rpmbuild/make_rpm_ubuntu26.py (in-tree packaging)
// jenkins-ci-rme/ (this pipeline)
//
// The build container image is the prebuilt image shipped in the repo as
// legatus-qt6_1.0.tar.gz; it is loaded onto the agent when not installed
// yet, never built here.
def project = params.ProjectName
def imageName = 'legatus-qt6:1.0'
def imageArchive = 'legatus-qt6_1.0.tar.gz'
env.GIT_TERMINAL_PROMPT = '0'
env.LTS_VERSION = "${params.LtsVersion}"
env.ARTIFACTREPO = 'https://internal-repo.sl.defence-elec.de'
// OS versions this build covers, built one after another (the builder
// stages the workspace into a shared deb_stage directory); output is
// still isolated under rpms/${project}/${osVersion}.
def osVersions = params.OsVersions.split(',').collect { it.trim() }.findAll { it }
def buildOsVersion = { String osVersion ->
def rpmsDir = "rpms/${project}/${osVersion}"
stage("Prepare ${project} (${osVersion})") {
sh "rm -rf ${rpmsDir}"
sh "mkdir -p ${rpmsDir}"
}
stage("Build DEB ${project} (${osVersion})") {
def buildContainer = docker.image("${imageName}")
def guezMode = (project == 'guez') ? 'ON' : 'OFF'
def dockerOpts = "--init --shm-size=2g" +
" -v ${WORKSPACE}:/workspace" +
" -e WORKSPACE=/workspace" +
" -e PROJECT_BASE_DIR=/workspace" +
" -e PROJECT=${project}" +
" -e OS_VERSION=${osVersion}" +
" -e LTS_VERSION=${LTS_VERSION}" +
" -e GUEZ_MODE=${guezMode}" +
" -e BUILD_NUMBER=${env.BUILD_NUMBER}" +
" -e BUILD_TAG=${env.BUILD_TAG}"
buildContainer.inside(dockerOpts) {
sh "bash /workspace/jenkins-ci-rme/jenkins_builder_ubuntu26.sh"
}
}
stage("Coverage ${project} (${osVersion})") {
if (!params.RunCoverage) {
echo "Coverage skipped for ${project} (OS ${osVersion}, RunCoverage=false)"
return
}
// The driver (run on the agent, same pattern as the image-build
// stage) builds the scope with -O0 --coverage, runs ctest and
// collects the lcov report into the workspace mount.
sh "bash ./new_docker_build.sh --docker-image ${imageName} --run-coverage --coverage-output-dir ${WORKSPACE}/coverage/${project}/${osVersion}"
archiveArtifacts artifacts: "coverage/${project}/${osVersion}/**", allowEmptyArchive: true
}
stage("Publish ${project} (${osVersion})") {
if (params.PublishArtifactRepo) {
withCredentials([usernamePassword(credentialsId: 'internal-repo-uploader',
usernameVariable: 'CURL_USER',
passwordVariable: 'CURL_PASS')]) {
sh """
export CURL_CRED="\${CURL_USER}:\${CURL_PASS}"
export PROJECT='${project}'
export OS_VERSION='${osVersion}'
export LTS_VERSION='${LTS_VERSION}'
export BUILD_NUMBER='${env.BUILD_NUMBER}'
export ARTIFACTREPO='${env.ARTIFACTREPO}'
export ARTIFACTFOLDER='${project}'
bash jenkins-ci-rme/jenkins_publisher_ubuntu26.sh
"""
}
def tdsUrl = readFile("url-${project}-${osVersion}.txt").trim()
def tdsVersion = readFile("tdsversion-${project}-${osVersion}.txt").trim()
def link = """<a href="${tdsUrl}" target="_blank">${project} ${tdsVersion} (OS ${osVersion})</a>"""
currentBuild.description = currentBuild.description ? "${currentBuild.description}<br/>${link}" : link
} else {
echo "Artifact-repo publish skipped for ${project} (OS ${osVersion}, PublishArtifactRepo=false)"
}
}
}
try {
stage("Initialization") {
echo "Legatus Qt6 release build initialized — branch '${env.BRANCH_NAME}', project: ${project}, LTS ${env.LTS_VERSION}, OS version(s): ${osVersions.join(', ')}"
}
stage("Install build image") {
// Reuse the prebuilt image when it is already installed on the agent;
// otherwise load it from the archive shipped in the repo.
def imageInstalled = sh(script: "docker image inspect '${imageName}' >/dev/null 2>&1", returnStatus: true) == 0
if (imageInstalled) {
echo "Build image ${imageName} is already installed on the agent - reusing it"
} else {
if (!fileExists(imageArchive)) {
error "Build image ${imageName} not installed and image archive ${imageArchive} not found in the workspace"
}
echo "Build image ${imageName} not installed on the agent - loading it from ${imageArchive}"
sh "docker load -i '${imageArchive}'"
if (sh(script: "docker image inspect '${imageName}' >/dev/null 2>&1", returnStatus: true) != 0) {
error "Build image ${imageName} still not available after loading ${imageArchive}"
}
echo "Build image ${imageName} installed on the agent"
}
}
for (osVersion in osVersions) {
buildOsVersion(osVersion)
}
stage("Finalization") {
echo "Legatus Qt6 release build completed — project: ${project} (LTS ${env.LTS_VERSION}), OS version(s): ${osVersions.join(', ')}"
}
currentBuild.result = 'SUCCESS'
} catch (e) {
currentBuild.result = 'FAILURE'
throw e
}
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
#
# Build the LTS DEB packages for the Qt6-migrated legatus release
# (validation scope: TetraIF, Z, Lts/Common + Lts/Proxies/TrainingAreaBase)
# for Ubuntu 26.04.
#
# Runs inside the prebuilt build container (built from the in-tree
# Dockerfile) with the pipeline workspace mounted at /workspace.
# Packaging is done by the IN-TREE rpmbuild copy
# (rpmbuild/ at the DLBO Qt6 repo root), so the
# release flow needs no files outside the source tree.
#
# Required environment (set by the Jenkinsfile or `docker run -e ...`):
# PROJECT LTS flavor: guez
# OS_VERSION Ubuntu version, e.g. 26.04
# LTS_VERSION Major.minor LTS version, e.g. 1.0
# GUEZ_MODE ON | OFF — cmake -DGUEZ_MODE
# WORKSPACE Container workspace path (/workspace)
# PROJECT_BASE_DIR Staging root inside the container (/workspace)
# BUILD_NUMBER Build number (used as release in the DEB version)
# BUILD_TAG Build tag
#
# IMPORTANT: Source files under git management must NEVER be deleted.
# Only the temporary staging directory (deb_stage) is removed.
set -eo pipefail
: "${PROJECT:?PROJECT must be set}"
: "${OS_VERSION:?OS_VERSION must be set}"
: "${LTS_VERSION:?LTS_VERSION must be set}"
: "${GUEZ_MODE:?GUEZ_MODE must be set}"
: "${WORKSPACE:?WORKSPACE must be set}"
: "${PROJECT_BASE_DIR:?PROJECT_BASE_DIR must be set}"
echo "Building LTS ${LTS_VERSION}-${BUILD_NUMBER:-?} DEB for project '${PROJECT}' (Ubuntu ${OS_VERSION})."
echo "PROJECT_BASE_DIR=${PROJECT_BASE_DIR}"
# Stage workspace as a clean copy under PROJECT_BASE_DIR/deb_stage.
STAGE_DIR="${PROJECT_BASE_DIR}/deb_stage"
rm -rf "${STAGE_DIR}"
mkdir -p "${STAGE_DIR}"
tar --exclude='./rpms' --exclude='./.git' --exclude='./build' \
--exclude='./deb_build_tmp' --exclude='./deb_stage' --exclude='./packages-out' \
--exclude='./legatus-qt6_1.0.tar.gz' \
-cf - -C "${WORKSPACE}" . | tar -xf - -C "${STAGE_DIR}"
export VERSION_DATE
VERSION_DATE=$(date +%Y-%m-%d)
# CMake project root inside the staged tree (the DLBO Qt6 repo root)
SOURCE_DIR="${STAGE_DIR}"
if [ ! -f "${SOURCE_DIR}/CMakeLists.txt" ] || [ ! -f "${SOURCE_DIR}/rpmbuild/make_rpm_ubuntu26.py" ]; then
echo "ERROR: staged source incomplete under ${SOURCE_DIR} (CMakeLists.txt or rpmbuild/make_rpm_ubuntu26.py missing)" >&2
exit 1
fi
# Output is isolated per OS version so parallel OS builds of the same
# project never collide
cd "${SOURCE_DIR}/rpmbuild"
python3 make_rpm_ubuntu26.py -c LTS \
--project_name "${PROJECT}" \
--version "${LTS_VERSION}" \
--output_dir "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/" \
--source_dir "${SOURCE_DIR}" \
--cmake_build_flags "-DUSE_IPO=ON -DUSE_UNITY_BUILD=ON -DGUEZ_MODE=${GUEZ_MODE} -DBUILD_WLS=ON -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/ -DRELEASE_BUILD=ON" \
--build_number "${BUILD_NUMBER:-1}" \
--release_scope
PACKAGE_OUT_DIR=/workspace/packages-out
mkdir -p "${PACKAGE_OUT_DIR}"
shopt -s nullglob
for deb in "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"*.deb; do
base="$(basename "${deb}")"
if [[ -e "${PACKAGE_OUT_DIR}/${base}" ]] &&
[[ "$(stat -c '%d:%i' "${deb}")" == "$(stat -c '%d:%i' "${PACKAGE_OUT_DIR}/${base}")" ]]; then
continue
fi
cp -f "${deb}" "${PACKAGE_OUT_DIR}/"
done
shopt -u nullglob
echo "DEB packages produced for '${PROJECT}' (Ubuntu ${OS_VERSION}):"
ls -lhR "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"
echo "DEB packages copied to ${PACKAGE_OUT_DIR}:"
ls -lh "${PACKAGE_OUT_DIR}/"
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
#
# Upload the produced DEBs to the internal artifact repository and emit two
# helper files for the Jenkinsfile to consume (named per project + OS
# version):
# ${WORKSPACE}/url-${PROJECT}-${OS_VERSION}.txt — browseable URL of the uploaded folder
# ${WORKSPACE}/tdsversion-${PROJECT}-${OS_VERSION}.txt — full version string (LTS-build)
#
# Adapted for the in-tree flow: make_rpm_ubuntu26.py writes the DEBs
# directly under ${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/ (no TDS
# subfolder), so that directory is uploaded as-is.
#
# Required environment (set by the Jenkinsfile / withCredentials):
# PROJECT LTS flavor: guez
# OS_VERSION Ubuntu base version, e.g. 26.04
# LTS_VERSION Major.minor LTS version, e.g. 1.0
# BUILD_NUMBER Build number (release component of the artifact name)
# WORKSPACE Jenkins workspace path
# ARTIFACTREPO Base URL of the internal repo (no trailing slash)
# ARTIFACTFOLDER Subfolder under cts-rpms/ (project name, e.g. guez)
# CURL_CRED user:password for the upload (Jenkins credential)
#
set -eo pipefail
: "${PROJECT:?PROJECT must be set}"
: "${OS_VERSION:?OS_VERSION must be set}"
: "${LTS_VERSION:?LTS_VERSION must be set}"
: "${BUILD_NUMBER:?BUILD_NUMBER must be set}"
: "${WORKSPACE:?WORKSPACE must be set}"
: "${ARTIFACTREPO:?ARTIFACTREPO must be set}"
: "${ARTIFACTFOLDER:?ARTIFACTFOLDER must be set}"
: "${CURL_CRED:?CURL_CRED must be set}"
tds_folder_name="${PROJECT}-TDS-${LTS_VERSION}-${BUILD_NUMBER}"
tds_folder_path="${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}"
tds_artifact_store="${ARTIFACTREPO}/repository/cts-rpms/${ARTIFACTFOLDER}/${OS_VERSION}/${tds_folder_name}"
if [ ! -d "${tds_folder_path}" ]; then
echo "ERROR: expected package folder not found: ${tds_folder_path}" >&2
exit 1
fi
shopt -s nullglob
uploaded=0
for file in "${tds_folder_path}"/*; do
[ -f "${file}" ] || continue
# Upload .deb, .dsc, .changes, .buildinfo files
if [[ "${file}" == *.deb ]] || [[ "${file}" == *.dsc ]] || [[ "${file}" == *.changes ]] || [[ "${file}" == *.buildinfo ]]; then
name=$(basename "${file}")
echo "Uploading: ${name}"
curl --fail --silent --show-error \
--user "${CURL_CRED}" \
--upload-file "${file}" \
"${tds_artifact_store}/${name}"
uploaded=$((uploaded + 1))
fi
done
shopt -u nullglob
if [ "${uploaded}" -eq 0 ]; then
echo "ERROR: no files uploaded from ${tds_folder_path}" >&2
exit 1
fi
echo "Uploaded ${uploaded} file(s) to ${tds_artifact_store}/"
# Per-(project, OS) filenames so concurrent publish stages don't clobber each
# other's helper files; the Jenkinsfile reads back the matching names.
echo "${ARTIFACTREPO}/service/rest/repository/browse/cts-rpms/${ARTIFACTFOLDER}/${OS_VERSION}/${tds_folder_name}/" > "${WORKSPACE}/url-${PROJECT}-${OS_VERSION}.txt"
echo "${LTS_VERSION}-${BUILD_NUMBER}" > "${WORKSPACE}/tdsversion-${PROJECT}-${OS_VERSION}.txt"
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
#
# Local release pipeline for the Qt6-migrated legatus validation scope
# (TetraIF, Z, Lts/Common + Lts/Proxies/TrainingAreaBase).
#
# Runs the in-tree new_docker_build.sh:
# - builds the prebuilt Docker image from the in-tree Dockerfile when the
# image is not present yet
# - builds the release scope, runs ctest and produces the release DEB
# packages with the in-tree rpmbuild script
# - collects the lcov code-coverage report (--run-coverage; set
# DRYRUN_COVERAGE=OFF to skip)
#
# The DEB packages land in ${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/
# (Jenkins-style layout; locally WORKSPACE is the pipeline root).
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LEGATUS_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
PIPELINE_ROOT="${LEGATUS_ROOT}"
# Release build configuration (Jenkins-style variables)
export WORKSPACE="${PIPELINE_ROOT}"
export PROJECT="${PROJECT:-guez}"
export OS_VERSION="${OS_VERSION:-26.04}"
export LTS_VERSION="${LTS_VERSION:-1.0}"
export GUEZ_MODE="${GUEZ_MODE:-ON}"
export BUILD_NUMBER="${BUILD_NUMBER:-$(date +%Y%m%d-%H%M%S)}"
export BUILD_TAG="${BUILD_TAG:-release-qt6-first}"
DOCKER_IMAGE="${DOCKER_IMAGE:-legatus-qt6:1.0}"
log_info() {
printf 'INFO: %s\n' "$*"
}
log_info "=== Qt6 Release Pipeline ==="
log_info "Pipeline root: ${PIPELINE_ROOT}"
log_info "Legatus root: ${LEGATUS_ROOT}"
log_info "Docker image: ${DOCKER_IMAGE}"
log_info "Build number: ${BUILD_NUMBER}"
log_info "Build tag: ${BUILD_TAG}"
log_info "Package output: ${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/"
cd "${LEGATUS_ROOT}"
# Build the prebuilt image from the in-tree Dockerfile when not present yet
# (--build-prebuilt-image builds the image and exits)
if ! docker image inspect "${DOCKER_IMAGE}" >/dev/null 2>&1; then
log_info "Prebuilt image not found - building it from the in-tree Dockerfile..."
bash ./new_docker_build.sh --build-prebuilt-image --docker-image "${DOCKER_IMAGE}"
fi
# Release scope build + ctest + DEB production (in-tree rpmbuild)
bash ./new_docker_build.sh \
--docker-image "${DOCKER_IMAGE}" \
--run-jenkins-builder \
--package-output-dir "${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}/" \
--project "${PROJECT}" \
--lts-version "${LTS_VERSION}" \
--build-number "${BUILD_NUMBER}" \
--build-tag "${BUILD_TAG}"
# Code coverage (lcov) - mirrors the Jenkins Coverage stage. Set
# DRYRUN_COVERAGE=OFF for a fast local DEB-only run.
DRYRUN_COVERAGE="${DRYRUN_COVERAGE:-ON}"
if [[ "${DRYRUN_COVERAGE}" == "ON" ]]; then
bash ./new_docker_build.sh \
--docker-image "${DOCKER_IMAGE}" \
--run-coverage \
--coverage-output-dir "${WORKSPACE}/coverage/${PROJECT}/${OS_VERSION}"
else
log_info "Coverage skipped (DRYRUN_COVERAGE=OFF)"
fi
log_info "=== Release Pipeline Complete ==="