Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSTALL-944: Improve CI pipeline to make it scalable #683

Merged
merged 10 commits into from
Apr 22, 2024
123 changes: 72 additions & 51 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,37 @@
* to use the software.
*/

def runBuildStage(String buildMode, String linkMode) {
def cmd = "python3 ${env.WORKSPACE}/resources/ci_cd/linux_build.py"
// TODO: Remove when merged
@Library("rticommunity-jenkins-pipelines@feature/enhance-examples-jenkinsfile") _

/**
* Build the examples in the specified build and link modes.
*
* @param buildMode The build mode name.
* @param linkMode The link mode name.
*/
void runBuildStage(String buildMode, String linkMode) {
String cmd = "python3 ${env.WORKSPACE}/resources/ci_cd/linux_build.py"
cmd += " --build-mode ${buildMode}"
cmd += " --link-mode ${linkMode}"
cmd += " --build-dir ${get_build_directory(buildMode, linkMode)}"
sh(cmd)
cmd += " --build-dir ${getBuildDirectory(buildMode, linkMode)}"
command.run(cmd)
}

def get_build_directory(String buildMode, String linkMode) {
/**
* Craft the build directory name.
*
* @param buildMode The build mode name.
* @param linkMode The link mode name.
*/
String getBuildDirectory(String buildMode, String linkMode) {
return "build_${buildMode}_${linkMode}"
}

pipeline {
agent none
agent {
label "${nodeManager.labelFromJobName()}"
}

options {
disableConcurrentBuilds()
Expand All @@ -47,71 +64,75 @@ pipeline {
timeout(time: 2, unit: 'HOURS')
}

stages {
stage('Build sequence') {
agent {
dockerfile {
filename 'resources/docker/Dockerfile.linux'
label 'docker'
}
}

environment {
RTI_INSTALLATION_PATH = "${env.WORKSPACE}"
}

stages {
stage('Download Packages') {
steps {
sh 'pip3 install -r resources/ci_cd/requirements.txt'
environment {
RTI_INSTALLATION_PATH = "${env.WORKSPACE}"
VIRTUAL_ENV = "${env.WORKSPACE}/.venv"
}

stages {
stage('Download Packages') {
steps {
script {
nodeManager.runInsideExecutor() {
command.run(
'pip3 install -r resources/ci_cd/requirements.txt'
)
withAWSCredentials {
withCredentials([
string(credentialsId: 's3-bucket', variable: 'RTI_AWS_BUCKET'),
string(credentialsId: 's3-path', variable: 'RTI_AWS_PATH'),
]) {
sh 'python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
command.run(
'python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
)
}
}
}
}

stage('Build all modes') {
matrix {
axes {
axis {
name 'buildMode'
values 'release', 'debug'
}
axis {
name 'linkMode'
values 'static', 'dynamic'
}
}
stages {
stage('Build single mode') {
steps {
}
}
stage('Build all modes') {
matrix {
axes {
axis {
name 'buildMode'
values 'release', 'debug'
}
axis {
name 'linkMode'
values 'static', 'dynamic'
}
}
stages {
stage('Build single mode') {
steps {
script{
nodeManager.runInsideExecutor() {
echo("Build ${buildMode}/${linkMode}")
runBuildStage(buildMode, linkMode)
}
}
}
}
}

stage('Static Analysis') {
steps {
sh "python3 resources/ci_cd/linux_static_analysis.py --build-dir ${get_build_directory('release', 'dynamic')}"
}
}
}

post {
cleanup {
cleanWs()
}
stage('Static Analysis') {
steps {
script {
nodeManager.runInsideExecutor() {
command.run("""
python3 resources/ci_cd/linux_static_analysis.py \
--build-dir ${getBuildDirectory('release', 'dynamic')}
""")
}
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}