99 * any incidental or consequential damages arising out of the use or inability
1010 * to use the software.
1111 */
12- def DETAILS_URL = " https://community.rti.com/"
13- def detailsText
12+ DETAILS_URL = " https://community.rti.com/"
13+
14+ def publishInProgressCheck (Map config ) {
15+ publishChecks(
16+ name : config. get(' name' , " ${ STAGE_NAME} " ),
17+ title : config. title,
18+ summary : config. summary,
19+ status : ' IN_PROGRESS' ,
20+ detailsURL : DETAILS_URL ,
21+ )
22+ }
23+
24+ def publishPassedCheck (Map config ) {
25+ publishChecks(
26+ name : config. get(' name' , " ${ STAGE_NAME} " ),
27+ title : ' Passed' ,
28+ summary : config. summary,
29+ status : ' COMPLETED' ,
30+ conclusion : ' SUCCESS' ,
31+ text : readFile(env. RTI_JENKINS_OUTPUT_FILE ),
32+ detailsURL : DETAILS_URL ,
33+ )
34+ }
35+
36+ def publishFailedCheck (Map config ) {
37+ publishChecks(
38+ name : config. get(' name' , " ${ STAGE_NAME} " ),
39+ title : ' Failed' ,
40+ summary : config. summary,
41+ status : ' COMPLETED' ,
42+ conclusion : ' FAILURE' ,
43+ text : readFile(env. RTI_JENKINS_OUTPUT_FILE ),
44+ detailsURL : DETAILS_URL ,
45+ )
46+ }
47+
48+ def publishAbortedCheck (Map config ) {
49+ publishChecks(
50+ name : config. get(' name' , " ${ STAGE_NAME} " ),
51+ title : ' Aborted' ,
52+ summary : config. summary,
53+ status : ' COMPLETED' ,
54+ conclusion : ' CANCELED' ,
55+ text : readFile(env. RTI_JENKINS_OUTPUT_FILE ),
56+ detailsURL : DETAILS_URL ,
57+ )
58+ }
59+
60+ def runBuildStage (String buildMode , String linkMode ) {
61+ def checkName = " Build ${ buildMode} /${ linkMode} "
62+ publishInProgressCheck(
63+ name : checkName,
64+ title : " Building ${ buildMode} /${ linkMode} " ,
65+ summary : ' :wrench: Building all the examples...' ,
66+ )
67+ def cmd = " python3 ${ env.WORKSPACE} /resources/ci_cd/linux_build.py"
68+ cmd + = " --build-mode ${ buildMode} "
69+ cmd + = " --link-mode ${ linkMode} "
70+ cmd + = " --build-dir ${ get_build_directory(buildMode, linkMode)} "
71+ cmd + = ' | tee $RTI_LOGS_FILE'
72+ def returnCode = sh(
73+ script : """ #!/bin/bash
74+ set -o pipefail
75+ ${ cmd}
76+ """ ,
77+ returnStatus : true ,
78+ )
79+
80+ sh ' python3 resources/ci_cd/jenkins_output.py'
81+ if (returnCode) {
82+ publishFailedCheck(
83+ name : checkName,
84+ summary : ' :warning: There was an error building the examples.' ,
85+ )
86+ error(
87+ ' There were errors building the examples in'
88+ + " ${ buildMode} mode when linking in"
89+ + " ${ linkMode} mode."
90+ )
91+ }
92+ publishPassedCheck(
93+ name : checkName,
94+ summary : ' :white_check_mark: All the examples were built succesfully.' ,
95+ )
96+ }
97+
98+ def get_build_directory (String buildMode , String linkMode ) {
99+ return " build_${ buildMode} _${ linkMode} "
100+ }
14101
15102pipeline {
16103 agent none
17104
18105 stages {
19106 stage(' Executor Check' ) {
20107 steps {
21- publishChecks detailsURL : DETAILS_URL , name : ' Waiting for executor' ,
22- status : ' IN_PROGRESS' , title : ' Waiting' ,
23- summary : ' :hourglass: Waiting for next available executor...'
108+ publishInProgressCheck(
109+ name : ' Waiting for executor' ,
110+ title : ' Waiting' ,
111+ summary : ' :hourglass: Waiting for next available executor...'
112+ )
24113 }
25114 }
26115
27116 stage(' Build sequence' ) {
28117 agent {
29118 dockerfile {
30- filename ' Dockerfile'
119+ filename ' resources/docker/ Dockerfile.x64Linux4gcc7.3.0 '
31120 label ' docker'
32121 }
33122 }
34123
35124 environment {
36- RTI_INSTALLATION_PATH = " ${ WORKSPACE} /unlicensed"
37- RTI_LOGS_FILE = " ${ WORKSPACE} /output_logs.txt"
125+ RTI_INSTALLATION_PATH = " ${ env.WORKSPACE} /unlicensed"
126+ RTI_LOGS_FILE = " ${ env.WORKSPACE} /output_logs.txt"
127+ RTI_JENKINS_OUTPUT_FILE = " ${ env.WORKSPACE} /jenkins_output.md"
38128 }
39129
40130 stages {
41131 stage(' Download Packages' ) {
42132 steps {
43- publishChecks detailsURL : DETAILS_URL , name : ' Waiting for executor' ,
44- summary : ' :white_check_mark: Build started.' ,
45- title : ' Passed'
46-
47133 sh ' python3 resources/ci_cd/jenkins_output.py'
134+ publishPassedCheck(
135+ name : ' Waiting for executor' ,
136+ summary : ' :white_check_mark: Executor found.' ,
137+ )
48138
49139 script {
50- detailsText = readFile(" jenkins_output.md" )
140+ connextdds_arch = sh(
141+ script : ' echo $CONNEXTDDS_ARCH' ,
142+ returnStdout : true
143+ ). trim()
51144 }
52145
53- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
54- status : ' IN_PROGRESS' , title : ' Downloading' , text : detailsText,
55- summary : ' :arrow_down: Downloading RTI Connext DDS libraries...'
146+ publishInProgressCheck(
147+ title : ' Downloading' ,
148+ summary : ' :arrow_down: Downloading RTI Connext DDS libraries...' ,
149+ )
56150
57151 rtDownload (
58152 serverId : ' rti-artifactory' ,
59- spec : ''' {
153+ spec : """ {
60154 "files": [
61155 {
62156 "pattern": "connext-ci/pro/weekly/",
63- "props": "rti.artifact.architecture=x64Linux4gcc7.3.0 ;rti.artifact.kind=staging",
157+ "props": "rti.artifact.architecture=${ connextdds_arch } ;rti.artifact.kind=staging",
64158 "sortBy": ["created"],
65159 "sortOrder": "desc",
66160 "limit": 1,
67161 "flat": true
68162 }]
69- }''' ,
163+ }""" ,
70164 )
71165
72166 // We cannot use the explode option because it is bugged.
73167 // https://www.jfrog.com/jira/browse/HAP-1154
74- sh ' tar zxvf connextdds-staging-x64Linux4gcc7.3.0.tgz unlicensed/'
75-
76- sh ' python3 resources/ci_cd/jenkins_output.py'
168+ sh ' tar zxvf connextdds-staging-${CONNEXTDDS_ARCH}.tgz unlicensed/'
77169
78- script {
79- detailsText = readFile(" jenkins_output.md" )
80- }
170+ sh '''
171+ cp ${RTI_INSTALLATION_PATH}/rti_connext_dds-*/lib/${CONNEXTDDS_ARCH}/openssl-1.*/* \
172+ ${RTI_INSTALLATION_PATH}/rti_connext_dds-*/lib/${CONNEXTDDS_ARCH}/
173+ '''
81174 }
82175
83176 post {
177+ always {
178+ sh ' python3 resources/ci_cd/jenkins_output.py'
179+ }
84180 success {
85- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
181+ publishPassedCheck(
86182 summary : ' :white_check_mark: RTI Connext DDS libraries downloaded.' ,
87- title : ' Passed ' , text : detailsText
183+ )
88184 }
89185 failure {
90- publishChecks conclusion : ' FAILURE ' , detailsURL : DETAILS_URL ,
91- name : STAGE_NAME , title : ' Failed' , text : detailsText ,
92- summary : ' :warning: Failed downloading RTI Connext DDS libraries. '
186+ publishFailedCheck(
187+ summary : ' :warning: Failed downloading RTI Connext DDS libraries. ' ,
188+ )
93189 }
94190 aborted {
95- publishChecks conclusion : ' CANCELED ' , detailsURL : DETAILS_URL ,
96- name : STAGE_NAME , title : ' Aborted ' , text : detailsText ,
97- summary : ' :no_entry: The download of RTI Connext DDS libraries was aborted. '
191+ publishAbortedCheck(
192+ summary : ' :no_entry: The download of RTI Connext DDS libraries was aborted. ' ,
193+ )
98194 }
99195 }
100196 }
101197
102- stage(' Build' ) {
103- steps {
104- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
105- status : ' IN_PROGRESS' , summary : ' :wrench: Building all the examples...' ,
106- title : ' Building' , text : detailsText
107-
108- sh """ #!/bin/bash
109- set -o pipefail
110- python3 resources/ci_cd/linux_build.py | tee $RTI_LOGS_FILE
111- """
112- }
113-
114- post {
115- always{
116- sh ' python3 resources/ci_cd/jenkins_output.py'
198+ stage(' Build all modes' ) {
199+ matrix {
200+ axes {
201+ axis {
202+ name ' buildMode'
203+ values ' release' , ' debug'
204+ }
205+ axis {
206+ name ' linkMode'
207+ values ' static' , ' dynamic'
208+ }
117209 }
118- success {
119- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
120- summary : ' :white_check_mark: All the examples were built succesfully.' ,
121- title : ' Passed' , text : readFile(" jenkins_output.md" )
122- }
123- failure {
124- publishChecks conclusion : ' FAILURE' , detailsURL : DETAILS_URL ,
125- name : STAGE_NAME , title : ' Failed' , text : readFile(" jenkins_output.md" ),
126- summary : ' :warning: There was an error building the examples.'
127- }
128- aborted {
129- publishChecks conclusion : ' CANCELED' , detailsURL : DETAILS_URL ,
130- name : STAGE_NAME , title : ' Aborted' , text : readFile(" jenkins_output.md" ),
131- summary : ' :no_entry: The examples build was aborted'
210+ stages {
211+ stage(' Build single mode' ) {
212+ environment {
213+ RTI_LOGS_FILE = " ${ env.WORKSPACE} /output_${ buildMode} _${ linkMode} .log"
214+ RTI_JENKINS_OUTPUT_FILE = " ${ env.WORKSPACE} /jenkins_output_${ buildMode} _${ linkMode} .md"
215+ }
216+ steps {
217+ echo(" Build ${ buildMode} /${ linkMode} " )
218+ runBuildStage(buildMode, linkMode)
219+ }
220+ post {
221+ aborted {
222+ publishAbortedCheck(
223+ summary : ' :no_entry: The build was aborted.' ,
224+ )
225+ }
226+ }
227+ }
132228 }
133229 }
134230 }
135231
136232 stage(' Static Analysis' ) {
137233 steps {
138- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
139- status : ' IN_PROGRESS' , title : ' In progress' , text : detailsText,
140- summary : ' :mag: Analysing all the examples...'
141-
142- sh """ #!/bin/bash
143- set -o pipefail
144- python3 resources/ci_cd/linux_static_analysis.py | tee $RTI_LOGS_FILE
145- """
234+ publishInProgressCheck(
235+ title : ' Analyzing' ,
236+ summary : ' :mag: Analyzing all the examples...' ,
237+ )
238+ script {
239+ cmd = ' python3 resources/ci_cd/linux_static_analysis.py'
240+ cmd + = " --build-dir ${ get_build_directory('release', 'dynamic')} "
241+ cmd + = ' | tee $RTI_LOGS_FILE'
242+ }
243+ sh """ #!/bin/bash
244+ set -o pipefail
245+ ${ cmd}
246+ """
146247 }
147248
148249 post {
149250 always {
150251 sh ' python3 resources/ci_cd/jenkins_output.py'
151252 }
152253 success {
153- publishChecks detailsURL : DETAILS_URL , name : STAGE_NAME ,
254+ publishPassedCheck(
154255 summary : ' :white_check_mark: Succesfully analysed' ,
155- title : ' Passed ' , text : readFile( " jenkins_output.md " )
256+ )
156257 }
157258 failure {
158- publishChecks conclusion : ' FAILURE ' , detailsURL : DETAILS_URL ,
159- name : STAGE_NAME , title : ' Failed ' , text : readFile( " jenkins_output.md " ) ,
160- summary : ' :warning: The static analysis failed '
259+ publishFailedCheck(
260+ summary : ' :warning: The static analysis failed ' ,
261+ )
161262 }
162263 aborted {
163- publishChecks conclusion : ' CANCELED ' , detailsURL : DETAILS_URL ,
164- name : STAGE_NAME , title : ' Aborted ' , text : readFile( " jenkins_output.md " ) ,
165- summary : ' :no_entry: The static analysis was aborted '
264+ publishAbortedCheck(
265+ summary : ' :no_entry: The static analysis was aborted ' ,
266+ )
166267 }
167268 }
168269 }
@@ -173,9 +274,10 @@ pipeline {
173274 cleanWs()
174275 }
175276 aborted {
176- publishChecks conclusion : ' CANCELED' , detailsURL : DETAILS_URL ,
177- name : ' Waiting for executor' , title : ' Aborted' ,
178- summary : ' :no_entry: The pipeline was aborted'
277+ publishAbortedCheck(
278+ name : ' Waiting for executor' ,
279+ summary : ' :no_entry: The pipeline was aborted' ,
280+ )
179281 }
180282 }
181283 }
0 commit comments