pipeline { agent { label 'fedora-testing' } parameters { string(name: 'QCOW2_URL', defaultValue: 'https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2') text(name: 'TEST_REPOS', defaultValue: 'https://github.com/org/test1\nhttps://github.com/org/test2') choice(name: 'MAX_PARALLEL', choices: ['1', '2', '3', '5'], description: 'Concurrent tests') } environment { IMAGES_DIR = '/var/lib/libvirt/images' BUILD_ID = "${env.BUILD_NUMBER}" } stages { stage('Download') { steps { sh './scripts/download-image.sh "${QCOW2_URL}" "${IMAGES_DIR}" > base.txt' script { env.BASE_IMAGE = readFile('base.txt').trim() } } } stage('Build Golden') { steps { sh './scripts/build-golden.sh "${BASE_IMAGE}" "${IMAGES_DIR}/golden-${BUILD_ID}.qcow2"' script { env.GOLDEN_IMAGE = "${IMAGES_DIR}/golden-${BUILD_ID}.qcow2" } } } stage('Run Tests') { steps { script { def repos = params.TEST_REPOS.split('\n').findAll { it.trim() } def tasks = [:] repos.each { repo -> def testName = repo.tokenize('/').last().replace('.git', '') tasks[testName] = { lock(resource: 'vm-slots', quantity: 1) { sh "./scripts/run-test.sh '${testName}' '${repo}' '${GOLDEN_IMAGE}'" } } } parallel tasks } } } } post { always { sh "./scripts/cleanup-all.sh '.*-${BUILD_ID}' || true" sh "rm -f '${IMAGES_DIR}/golden-${BUILD_ID}.qcow2' || true" } } }