-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
What is your question?
I'm having a problem with building multiple targets with Jenkins jobs in parallel using CMakePresets.
The source code is checkout once, and a build folder for each target job is created.
I had to create a CONAN_HOME folder per job since the Conan cache failed when trying multiple jobs using the same folder. But that's okay.
The issue I'm having is with the root file CMakePresets.json which Conan adds as the preset's include path in this file.
As there are several jobs, each one compiling a target, each one edits the CMakePresets.json adding the preset path.
But when the job ends and the build folder is deleted, CMakePresets.json becomes with a dangling path that the other build will give an error when invoking cmake --preset android-release saying that another preset --linux-release no longer exists.
The pipeline is something like this:
stage('Build Setup Packages') {
steps {
script {
def buildMatrix = [:]
def failedBuilds = []
def versions = ['light', 'pro']
def targets = ['linux-x86', 'windows', 'android']
for (def version in versions) {
for (def target in targets) {
def jobName = "${target}-${version}"
def buildDir = "build_${target}_${version}"
def thisTarget = target
def thisVersion = version
buildMatrix[jobName] = {
stage("Build ${jobName}") {
// Run make_setup.sh with BUILD_FOLDER set to job-specific directory a local Conan cache
sh """#!/bin/bash
cd /workdir
mkdir -p ${buildDir}
export BUILD_FOLDER="${buildDir}"
export CONAN_HOME="/workdir/.conan_${jobName}"
mkdir -p "\${CONAN_HOME}/profiles"
cp -r /home/builder/.conan2/profiles/* "\${CONAN_HOME}/profiles"
conan remote disable conancenter 1> /dev/null
conan remote add artifactory-packages "${artifactory_pkg_url}" 1> /dev/null
echo "Building ${jobName} with \$(nproc) parallel jobs"
scripts/make_setup.sh "${thisTarget}" "${thisVersion}"
"""
}
}
}
def results = parallel(buildMatrix)
...
}The script make_setup.sh basically does something like this:
eval "conan install . -pr:h ./conan_profiles/{arch} -pr:b default -s build_type=${BUILD_TYPE^} -b missing -b outdated -c tools.cmake.cmake_layout:build_folder_vars='[\"const.${BUILD_PRESET}\"]'"
cmake --preset conan-${BUILD_PRESET}-${BUILD_TYPE,,}
cmake --build --preset conan-${BUILD_PRESET}-${BUILD_TYPE,,} -j$(nproc)
Would it be possible for Conan to edit and CMake to use CMakePresets.json defined in a build directory instead of the source directory to avoid collision? I wanted to avoid having to do code checkouts or source copy to be able to launch compilation jobs for each target.
I was able to reduce the occurrence of dangling paths in CMakePresets.json by deleting the file before invoking conan install ... & cmake --preset conan-xxx.
But even so, I've had problems with a job failing because it couldn't find the preset because it was deleted by another one:
16:05:44 conanfile.py (project/0.1): Generating aggregated env files
16:05:44 conanfile.py (project/0.1): Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
16:05:44 Install finished successfully
16:05:44 CMake Error: Could not read presets from /workdir:
16:05:44 File not found: /workdir/CMakePresets.json
I know it's a bit confusing, but any suggestions on how to implement parallel CI/CD pipeline Jenkins jobs with Conan and CMake Presets?
Thanks!
Have you read the CONTRIBUTING guide?
- I've read the CONTRIBUTING guide