1010 * to use the software.
1111 */
1212
13- def runBuildStage (String buildMode , String linkMode ) {
14- def cmd = " python3 ${ env.WORKSPACE} /resources/ci_cd/linux_build.py"
13+ /**
14+ * Build the examples in the specified build and link modes.
15+ *
16+ * @param buildMode The build mode name.
17+ * @param linkMode The link mode name.
18+ */
19+ void runBuildStage (String buildMode , String linkMode ) {
20+ String cmd = " python3 ${ env.WORKSPACE} /resources/ci_cd/linux_build.py"
1521 cmd + = " --build-mode ${ buildMode} "
1622 cmd + = " --link-mode ${ linkMode} "
17- cmd + = " --build-dir ${ get_build_directory (buildMode, linkMode)} "
18- sh (cmd)
23+ cmd + = " --build-dir ${ getBuildDirectory (buildMode, linkMode)} "
24+ command . run (cmd)
1925}
2026
21- def get_build_directory (String buildMode , String linkMode ) {
27+ /**
28+ * Craft the build directory name.
29+ *
30+ * @param buildMode The build mode name.
31+ * @param linkMode The link mode name.
32+ */
33+ String getBuildDirectory (String buildMode , String linkMode ) {
2234 return " build_${ buildMode} _${ linkMode} "
2335}
2436
2537pipeline {
26- agent none
38+ agent {
39+ label " ${ nodeManager.labelFromJobName()} "
40+ }
2741
2842 options {
2943 disableConcurrentBuilds()
@@ -47,71 +61,76 @@ pipeline {
4761 timeout(time : 2 , unit : ' HOURS' )
4862 }
4963
50- stages {
51- stage(' Build sequence' ) {
52- agent {
53- dockerfile {
54- filename ' resources/docker/Dockerfile.linux'
55- label ' docker'
56- }
57- }
58-
59- environment {
60- RTI_INSTALLATION_PATH = " ${ env.WORKSPACE} "
61- }
62-
63- stages {
64- stage(' Download Packages' ) {
65- steps {
66- sh ' pip3 install -r resources/ci_cd/requirements.txt'
64+ environment {
65+ RTI_INSTALLATION_PATH = " ${ env.WORKSPACE} "
66+ VIRTUAL_ENV = " ${ env.WORKSPACE} /.venv"
67+ }
6768
69+ stages {
70+ stage(' Download Packages' ) {
71+ steps {
72+ script {
73+ nodeManager. runInsideExecutor() {
74+ command. run(
75+ ' pip3 install -r resources/ci_cd/requirements.txt'
76+ )
6877 withAWSCredentials {
6978 withCredentials([
7079 string(credentialsId : ' s3-bucket' , variable : ' RTI_AWS_BUCKET' ),
7180 string(credentialsId : ' s3-path' , variable : ' RTI_AWS_PATH' ),
7281 ]) {
73- sh ' python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
82+ command. run(
83+ ' python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
84+ )
7485 }
7586 }
7687 }
7788 }
78-
79- stage(' Build all modes' ) {
80- matrix {
81- axes {
82- axis {
83- name ' buildMode'
84- values ' release' , ' debug'
85- }
86- axis {
87- name ' linkMode'
88- values ' static' , ' dynamic'
89- }
90- }
91- stages {
92- stage(' Build single mode' ) {
93- steps {
89+ }
90+ }
91+ stage(' Build all modes' ) {
92+ matrix {
93+ axes {
94+ axis {
95+ name ' buildMode'
96+ values ' release' , ' debug'
97+ }
98+ axis {
99+ name ' linkMode'
100+ values ' static' , ' dynamic'
101+ }
102+ }
103+ stages {
104+ stage(' Build single mode' ) {
105+ steps {
106+ script{
107+ nodeManager. runInsideExecutor() {
94108 echo(" Build ${ buildMode} /${ linkMode} " )
95109 runBuildStage(buildMode, linkMode)
96110 }
97111 }
98112 }
99113 }
100114 }
101-
102- stage(' Static Analysis' ) {
103- steps {
104- sh " python3 resources/ci_cd/linux_static_analysis.py --build-dir ${ get_build_directory('release', 'dynamic')} "
105- }
106- }
107115 }
108-
109- post {
110- cleanup {
111- cleanWs()
116+ }
117+ stage(' Static Analysis' ) {
118+ steps {
119+ script {
120+ nodeManager. runInsideExecutor() {
121+ command. run("""
122+ python3 resources/ci_cd/linux_static_analysis.py \
123+ --build-dir ${ getBuildDirectory('release', 'dynamic')}
124+ """ )
125+ }
112126 }
113127 }
114128 }
115129 }
130+ post {
131+ cleanup {
132+ cleanWs()
133+ }
134+ }
116135}
117136
0 commit comments