diff --git a/Jenkinsfile b/Jenkinsfile index 701d4d243ed..47f74bee42d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ def baseTests(String image) { Map base_tests = [failFast: false]; base_tests['Unit Tests CTest'] = { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup CTest') { echo 'Nothing to be done.'; } @@ -27,7 +27,7 @@ def baseTests(String image) { base_tests['Unit Tests Tcl'] = { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup Tcl Tests') { sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; checkout scm; @@ -68,7 +68,7 @@ def baseTests(String image) { flow_tests.each { current_test -> base_tests["Flow Test - ${current_test}"] = { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage("Setup ${current_test}") { sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; checkout scm; @@ -104,7 +104,7 @@ def getParallelTests(String image) { 'Build without GUI': { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup no-GUI Build') { echo "Build without GUI"; sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; @@ -121,7 +121,7 @@ def getParallelTests(String image) { 'Build without Test': { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup no-test Build') { echo "Build without Tests"; sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; @@ -148,7 +148,7 @@ def getParallelTests(String image) { 'Unit Tests Ninja': { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup Ninja Tests') { sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; checkout scm; @@ -174,7 +174,7 @@ def getParallelTests(String image) { 'Compile with C++20': { node { - docker.image(image).inside('--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock') { + withDockerContainer(args: '-u root', image: image) { stage('Setup C++20 Compile') { sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; checkout scm; @@ -188,6 +188,41 @@ def getParallelTests(String image) { ]; + deb_os = [ + [name: 'Ubuntu 20.04' , image: 'openroad/ubuntu20.04-dev'], + [name: 'Ubuntu 22.04' , image: 'openroad/ubuntu22.04-dev'], + [name: 'Debian 11' , image: 'openroad/debian11-dev'] + ]; + + deb_os.each { os -> + ret["Build .deb - ${os.name}"] = { + node { + stage('Setup and Build') { + sh label: 'Pull latest image', script: "docker pull ${os.image}:latest"; + withDockerContainer(args: '-u root', image: "${os.image}") { + sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; + checkout([ + $class: 'GitSCM', + branches: [[name: scm.branches[0].name]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'CloneOption', noTags: false], + [$class: 'SubmoduleOption', recursiveSubmodules: true] + ], + submoduleCfg: [], + userRemoteConfigs: scm.userRemoteConfigs + ]); + def version = sh(script: 'git describe | sed s,^v,,', returnStdout: true).trim(); + sh label: 'Create Changelog', script: "./debian/create-changelog.sh ${version}"; + sh label: 'Run debuild', script: 'debuild --preserve-env --preserve-envvar=PATH -B -j$(nproc)'; + sh label: 'Move generated files', script: "./debian/move-artifacts.sh ${version}"; + archiveArtifacts artifacts: '*' + "${version}" + '*'; + } + } + } + } + } + return ret; } @@ -196,7 +231,26 @@ node { checkout scm; } def DOCKER_IMAGE; - stage('Build and Push Docker Image') { + stage('Build, Test and Push Docker Image') { + Map build_docker_images = [failFast: false]; + test_os = [ + [name: 'Ubuntu 20.04', base: 'ubuntu:20.04', image: 'ubuntu20.04'], + [name: 'Ubuntu 22.04', base: 'ubuntu:22.04', image: 'ubuntu22.04'], + [name: 'Ubuntu 24.04', base: 'ubuntu:24.04', image: 'ubuntu24.04'], + [name: 'RedHat 9', base: 'rhel/ubi9:latest', image: 'rhel9'], + [name: 'Debian 11', base: 'debian:11', image: 'debian11'] + ]; + test_os.each { os -> + build_docker_images["Test Installer - ${os.name}"] = { + node { + checkout scm; + sh label: 'Build Docker image', script: "./etc/DockerHelper.sh create -target=builder -os=${os.image}"; + sh label: 'Test Docker image', script: "./etc/DockerHelper.sh test -target=builder -os=${os.image}"; + dockerPush("${os.image}", 'openroad'); + } + } + } + parallel(build_docker_images); DOCKER_IMAGE = dockerPush('ubuntu22.04', 'openroad'); echo "Docker image is ${DOCKER_IMAGE}"; } diff --git a/debian/move-artifacts.sh b/debian/move-artifacts.sh new file mode 100755 index 00000000000..16b0d332a3b --- /dev/null +++ b/debian/move-artifacts.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [[ $# -ne 1 ]]; then + echo "Error: This script requires exactly one argument." + echo "usage: $0 " + exit 1 +fi + +for file in ../*${1}*; do + base_name=$(basename "$file") + name="${base_name%.*}" + ext="${base_name##*.}" + mv "$file" "${name}-${os_name}.${ext}" +done