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"
15- cmd + = " --build-mode ${ buildMode} "
16- cmd + = " --link-mode ${ linkMode} "
17- cmd + = " --build-dir ${ get_build_directory(buildMode, linkMode)} "
18- sh(cmd)
19- }
20-
21- def get_build_directory (String buildMode , String linkMode ) {
22- return " build_${ buildMode} _${ linkMode} "
23- }
13+ /**
14+ * Hold information about the pipeline.
15+ */
16+ Map pipelineInfo = [:]
2417
2518pipeline {
26- agent none
19+ agent {
20+ label " ${ runInsideExecutor.labelFromJobName()} "
21+ }
2722
2823 options {
24+ skipDefaultCheckout()
2925 disableConcurrentBuilds()
3026 /*
3127 To avoid excessive resource usage in server, we limit the number
@@ -48,70 +44,102 @@ pipeline {
4844 }
4945
5046 stages {
51- stage(' Build sequence' ) {
52- agent {
53- dockerfile {
54- filename ' resources/docker/Dockerfile.linux'
55- label ' docker'
47+ stage(' Configuration' ) {
48+ steps {
49+ script {
50+ checkoutCommunityRepoBranch(
51+ ' rticonnextdds-examples' ,
52+ env. BRANCH_NAME ,
53+ false ,
54+ )
55+ pipelineInfo. dockerDir = " ${ env.WORKSPACE} /resources/docker/"
56+ pipelineInfo. staticAnalysisDir = " ${ env.WORKSPACE} /static_analysis_report"
57+ runInsideExecutor(
58+ ' ' ,
59+ pipelineInfo. dockerDir,
60+ ) {
61+ pipelineInfo. connextArch = getEnvVar(' CONNEXTDDS_ARCH' )
62+ }
5663 }
5764 }
58-
59- environment {
60- RTI_INSTALLATION_PATH = " ${ env.WORKSPACE} "
65+ }
66+ stage(' Download Packages' ) {
67+ steps {
68+ runInsideExecutor(
69+ ' ' ,
70+ pipelineInfo. dockerDir,
71+ ) {
72+ script {
73+ def version = readFile(' VERSION' ). readLines()[0 ]. trim()
74+ pipelineInfo. connextDir = installConnext(
75+ pipelineInfo. connextArch,
76+ env. WORKSPACE ,
77+ version
78+ )
79+ }
80+ }
6181 }
62-
63- stages {
64- stage(' Download Packages' ) {
65- steps {
66- sh ' pip3 install -r resources/ci_cd/requirements.txt'
67-
68- withAWSCredentials {
69- withCredentials([
70- string(credentialsId : ' s3-bucket' , variable : ' RTI_AWS_BUCKET' ),
71- string(credentialsId : ' s3-path' , variable : ' RTI_AWS_PATH' ),
72- ]) {
73- sh ' python3 resources/ci_cd/linux_install.py -a $CONNEXTDDS_ARCH'
74- }
75- }
82+ }
83+ stage(' Build all modes' ) {
84+ matrix {
85+ axes {
86+ axis {
87+ name ' buildMode'
88+ values ' release' , ' debug'
89+ }
90+ axis {
91+ name ' linkMode'
92+ values ' static' , ' dynamic'
7693 }
7794 }
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 {
94- echo(" Build ${ buildMode} /${ linkMode} " )
95- runBuildStage(buildMode, linkMode)
96- }
95+ stages {
96+ stage(' Build single mode' ) {
97+ steps {
98+ runInsideExecutor(
99+ ' ' ,
100+ pipelineInfo. dockerDir,
101+ ) {
102+ echo(" Building ${ buildMode} /${ linkMode} " )
103+ buildExamples(
104+ pipelineInfo. connextArch,
105+ pipelineInfo. connextDir,
106+ buildMode,
107+ linkMode,
108+ env. WORKSPACE ,
109+ )
97110 }
98111 }
99112 }
100113 }
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- }
107114 }
108-
109- post {
110- cleanup {
111- cleanWs()
115+ }
116+ stage(' Static Analysis' ) {
117+ steps {
118+ runInsideExecutor(
119+ ' ' ,
120+ pipelineInfo. dockerDir,
121+ ) {
122+ runStaticAnalysis(
123+ buildExamples. getBuildDirectory(' release' , ' dynamic' ),
124+ pipelineInfo. connextDir,
125+ pipelineInfo. staticAnalysisDir,
126+ )
112127 }
128+ publishHTML(target : [
129+ allowMissing : true ,
130+ alwaysLinkToLastBuild : true ,
131+ keepAll : true ,
132+ reportDir : pipelineInfo. staticAnalysisDir,
133+ reportFiles : ' index.html' ,
134+ reportName : ' LLVM Scan build static analysis' ,
135+ ])
113136 }
114137 }
115138 }
139+ post {
140+ cleanup {
141+ cleanWs()
142+ }
143+ }
116144}
117145
0 commit comments