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
107 changes: 87 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,35 @@
* 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)}"
if (runCommand(cmd)) {
error(
'There was an error building the examples for the build'
+ " configuration ${buildMode}/${linkMode}"
)
}
}

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}"
}

Expand Down Expand Up @@ -47,30 +67,64 @@ pipeline {
timeout(time: 2, unit: 'HOURS')
}

parameters {
string(
name: 'CMAKE_UTILS_REFERENCE',
description: '''
rticommunity/rticonnextdds-cmake-utils repository reference to use (Branch or PR).
E.g.: PR-123, release/7.3.0, master
''',
defaultValue: '',
trim: true,
)
}

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

environment {
RTI_INSTALLATION_PATH = "${env.WORKSPACE}"
VIRTUAL_ENV = "${env.WORKSPACE}/.venv"
}

stages {
stage('Select CMake utils version') {
steps {
script {
switchBranch(
params.CMAKE_UTILS_REFERENCE,
"${env.WORKSPACE}/resources/cmake/rticonnextdds-cmake-utils",
)
}
}
}

stage('Download Packages') {
steps {
sh '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'
script {
nodeManager.runInsideExecutor() {
if (runCommand(
'pip3 install -r resources/ci_cd/requirements.txt'
)) {
error('An error ocurred installing Python dependencies')
}

withAWSCredentials {
withCredentials([
string(credentialsId: 's3-bucket', variable: 'RTI_AWS_BUCKET'),
string(credentialsId: 's3-path', variable: 'RTI_AWS_PATH'),
]) {

if (runCommand(
'python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
)) {
error('An error ocurred installing the Connext framework')
}
}
}
}
}
}
Expand All @@ -91,8 +145,12 @@ pipeline {
stages {
stage('Build single mode') {
steps {
echo("Build ${buildMode}/${linkMode}")
runBuildStage(buildMode, linkMode)
script{
nodeManager.runInsideExecutor() {
echo("Build ${buildMode}/${linkMode}")
runBuildStage(buildMode, linkMode)
}
}
}
}
}
Expand All @@ -101,7 +159,16 @@ pipeline {

stage('Static Analysis') {
steps {
sh "python3 resources/ci_cd/linux_static_analysis.py --build-dir ${get_build_directory('release', 'dynamic')}"
script {
nodeManager.runInsideExecutor() {
if (runCommand("""
python3 resources/ci_cd/linux_static_analysis.py \
--build-dir ${getBuildDirectory('release', 'dynamic')}
""")) {
error('An error ocurred running the static analysis')
}
}
}
}
}
}
Expand Down