Changes in Jenkinsfile [abc2a643:e11957e]
- File:
-
- 1 edited
-
Jenkinsfile (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Jenkinsfile
rabc2a643 re11957e 2 2 3 3 import groovy.transform.Field 4 5 // For skipping stages 6 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils 4 7 5 8 //=========================================================================================================== … … 12 15 SrcDir = pwd tmp: false 13 16 Settings = null 14 Tools = null17 StageName = '' 15 18 16 19 // Local variables … … 30 33 SrcDir = pwd tmp: false 31 34 32 Tools.Clean()33 34 Tools.Checkout()35 clean() 36 37 checkout() 35 38 36 39 build() … … 54 57 //attach the build log to the email 55 58 catch (Exception caughtError) { 56 // Store the result of the build log 57 currentBuild.result = "FAILURE" 58 59 // An error has occured, the build log is relevent 59 //rethrow error later 60 err = caughtError 61 62 echo err.toString() 63 64 //An error has occured, the build log is relevent 60 65 log_needed = true 61 66 62 // rethrow error later 63 err = caughtError 64 65 // print the error so it shows in the log 66 echo err.toString() 67 //Store the result of the build log 68 currentBuild.result = "${StageName} FAILURE".trim() 67 69 } 68 70 … … 82 84 // Main compilation routines 83 85 //=========================================================================================================== 86 def clean() { 87 build_stage('Cleanup', true) { 88 // clean the build by wipping the build directory 89 dir(BuildDir) { 90 deleteDir() 91 } 92 } 93 } 94 95 //Compilation script is done here but environnement set-up and error handling is done in main loop 96 def checkout() { 97 build_stage('Checkout', true) { 98 //checkout the source code and clean the repo 99 final scmVars = checkout scm 100 Settings.GitNewRef = scmVars.GIT_COMMIT 101 Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT 102 103 echo GitLogMessage() 104 105 // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles 106 // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles 107 // and these cause more problems. 108 sh 'find . -name Makefile.in -exec touch {} +' 109 } 110 } 111 84 112 def build() { 85 113 debug = true 86 114 release = Settings.RunAllTests || Settings.RunBenchmark 87 Tools.BuildStage('Build : configure', true) { 88 // Configure must be run inside the tree 89 dir (SrcDir) { 90 // Generate the necessary build files 91 sh './autogen.sh' 92 } 93 115 build_stage('Build : configure', true) { 94 116 // Build outside of the src tree to ease cleaning 95 117 dir (BuildDir) { 96 //Configure the co mpilation (Output is not relevant)118 //Configure the conpilation (Output is not relevant) 97 119 //Use the current directory as the installation target so nothing escapes the sandbox 98 120 //Also specify the compiler by hand … … 104 126 } 105 127 106 ast = Settings.NewAST ? "--enable-new-ast" : "--disable-new-ast" 107 108 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} ${ast} --quiet --prefix=${BuildDir}" 128 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet" 109 129 110 130 // Configure libcfa … … 113 133 } 114 134 115 Tools.BuildStage('Build : cfa-cpp', true) {135 build_stage('Build : cfa-cpp', true) { 116 136 // Build outside of the src tree to ease cleaning 117 137 dir (BuildDir) { … … 124 144 } 125 145 126 Tools.BuildStage('Build : libcfa(debug)', debug) {146 build_stage('Build : libcfa(debug)', debug) { 127 147 // Build outside of the src tree to ease cleaning 128 148 dir (BuildDir) { … … 131 151 } 132 152 133 Tools.BuildStage('Build : libcfa(nodebug)', release) {153 build_stage('Build : libcfa(nodebug)', release) { 134 154 // Build outside of the src tree to ease cleaning 135 155 dir (BuildDir) { … … 137 157 } 138 158 } 139 140 Tools.BuildStage('Build : install', true) {141 // Build outside of the src tree to ease cleaning142 dir (BuildDir) {143 sh "make -j 8 --no-print-directory install"144 }145 }146 159 } 147 160 148 161 def test() { 149 162 try { 150 Tools.BuildStage('Test: short', !Settings.RunAllTests) {163 build_stage('Test: short', !Settings.RunAllTests) { 151 164 dir (BuildDir) { 152 165 //Run the tests from the tests directory … … 155 168 } 156 169 157 Tools.BuildStage('Test: full', Settings.RunAllTests) {170 build_stage('Test: full', Settings.RunAllTests) { 158 171 dir (BuildDir) { 159 172 //Run the tests from the tests directory … … 166 179 echo "Archiving core dumps" 167 180 dir (BuildDir) { 168 archiveArtifacts artifacts: "tests/crashes/**/* ,lib/**/lib*.so*", fingerprint: true181 archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true 169 182 } 170 183 throw err … … 173 186 174 187 def benchmark() { 175 Tools.BuildStage('Benchmark', Settings.RunBenchmark) {188 build_stage('Benchmark', Settings.RunBenchmark) { 176 189 dir (BuildDir) { 177 190 //Append bench results … … 182 195 183 196 def build_doc() { 184 Tools.BuildStage('Documentation', Settings.BuildDocumentation) {197 build_stage('Documentation', Settings.BuildDocumentation) { 185 198 dir ('doc/user') { 186 199 make_doc() … … 194 207 195 208 def publish() { 196 Tools.BuildStage('Publish', true) {209 build_stage('Publish', true) { 197 210 198 211 if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' } … … 202 215 203 216 //Then publish the results 204 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation')205 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)')206 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching')207 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')208 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion')209 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)')210 do_plot(Settings.RunBenchmark && Settings.Publish, 's cheduling', groupConcurrency, false, 'Internal and External Scheduling')211 do_plot(Settings.RunBenchmark && Settings.Publish, 's cheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')217 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation') 218 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)') 219 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching') 220 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)') 221 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion') 222 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)') 223 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal' , groupConcurrency, false, 'Internal and External Scheduling') 224 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff' , groupConcurrency, true , 'Internal and External Scheduling (relative)') 212 225 } 213 226 } … … 216 229 //Routine responsible of sending the email notification once the build is completed 217 230 //=========================================================================================================== 231 @NonCPS 232 def SplitLines(String text) { 233 def list = [] 234 235 text.eachLine { 236 list += it 237 } 238 239 return list 240 } 241 242 def GitLogMessage() { 243 if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n" 244 245 def oldRef = Settings.GitOldRef 246 def newRef = Settings.GitNewRef 247 248 def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim() 249 def revList = SplitLines( revText ) 250 251 def gitUpdate = "" 252 revList.each { rev -> 253 def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim() 254 gitUpdate = gitUpdate + " via ${rev} (${type})" 255 } 256 257 def rev = oldRef 258 def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim() 259 gitUpdate = gitUpdate + " from ${rev} (${type})" 260 261 def gitLog = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim() 262 263 def gitDiff = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim() 264 gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">') 265 gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">') 266 gitDiff = gitDiff.replace('[m', '</span>') 267 268 return """ 269 <pre> 270 The branch ${env.BRANCH_NAME} has been updated. 271 ${gitUpdate} 272 </pre> 273 274 <p>Check console output at ${env.BUILD_URL} to view the results.</p> 275 276 <p>- Status --------------------------------------------------------------</p> 277 278 <p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p> 279 280 <p>- Log -----------------------------------------------------------------</p> 281 282 <pre> 283 ${gitLog} 284 </pre> 285 286 <p>-----------------------------------------------------------------------</p> 287 <pre> 288 Summary of changes: 289 ${gitDiff} 290 </pre> 291 """ 292 } 293 218 294 //Standard build email notification 219 295 def email(boolean log) { … … 227 303 generated because of a git hooks/post-receive script following 228 304 a ref change which was pushed to the C\u2200 repository.</p> 229 """ + Tools.GitLogMessage()305 """ + GitLogMessage() 230 306 231 307 def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca" … … 249 325 public String CXX 250 326 public String CC 251 public String lto 252 253 CC_Desc(String name, String CXX, String CC, String lto) { 327 328 CC_Desc(String name, String CXX, String CC) { 254 329 this.name = name 255 330 this.CXX = CXX 256 this.CC = CC 257 this.lto = lto 331 this.CC = CC 258 332 } 259 333 } … … 275 349 public final CC_Desc Compiler 276 350 public final Arch_Desc Architecture 277 public final Boolean NewAST278 351 public final Boolean RunAllTests 279 352 public final Boolean RunBenchmark … … 291 364 switch( param.Compiler ) { 292 365 case 'gcc-9': 293 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9' , '-flto=auto')366 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9') 294 367 break 295 368 case 'gcc-8': 296 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8' , '-flto=auto')369 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8') 297 370 break 298 371 case 'gcc-7': 299 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7' , '-flto=auto')372 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7') 300 373 break 301 374 case 'gcc-6': 302 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6' , '-flto=auto')375 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6') 303 376 break 304 377 case 'gcc-5': 305 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5' , '-flto=auto')378 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5') 306 379 break 307 380 case 'gcc-4.9': 308 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9' , '-flto=auto')381 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9') 309 382 break 310 383 case 'clang': 311 this.Compiler = new CC_Desc('clang', 'clang++- 10', 'gcc-9', '-flto=thin -flto-jobs=0')384 this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6') 312 385 break 313 386 default : … … 327 400 328 401 this.IsSandbox = (branch == "jenkins-sandbox") 329 this.NewAST = param.NewAST330 402 this.RunAllTests = param.RunAllTests 331 403 this.RunBenchmark = param.RunBenchmark … … 337 409 this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}" 338 410 339 final ast = this.NewAST ? "New AST" : "Old AST"340 411 this.DescLong = """Compiler : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC }) 341 AST Version : ${ ast.toString() }342 412 Architecture : ${ this.Architecture.name } 343 413 Arc Flags : ${ this.Architecture.flags } … … 369 439 // prepare the properties 370 440 properties ([ \ 371 buildDiscarder(logRotator( \372 artifactDaysToKeepStr: '', \373 artifactNumToKeepStr: '', \374 daysToKeepStr: '730', \375 numToKeepStr: '1000' \376 )), \377 441 [$class: 'ParametersDefinitionProperty', \ 378 442 parameterDefinitions: [ \ … … 380 444 description: 'Which compiler to use', \ 381 445 name: 'Compiler', \ 382 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \446 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \ 383 447 defaultValue: 'gcc-8', \ 384 448 ], \ … … 389 453 defaultValue: 'x64', \ 390 454 ], \ 391 [$class: 'BooleanParameterDefinition', \392 description: 'If true, build compiler using new AST', \393 name: 'NewAST', \394 defaultValue: true, \395 ], \396 455 [$class: 'BooleanParameterDefinition', \ 397 456 description: 'If false, only the quick test suite is ran', \ … … 422 481 ]]) 423 482 424 // It's unfortunate but it looks like we need to checkout the entire repo just to get 425 // - the pretty git printer 426 // - Jenkins.tools 483 // It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer 427 484 checkout scm 428 429 Tools = load "Jenkins/tools.groovy"430 485 431 486 final settings = new BuildSettings(params, env.BRANCH_NAME) … … 435 490 436 491 return settings 492 } 493 494 def build_stage(String name, boolean run, Closure block ) { 495 StageName = name 496 echo " -------- ${StageName} -------- " 497 if(run) { 498 stage(name, block) 499 } else { 500 stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) } 501 } 437 502 } 438 503
Note:
See TracChangeset
for help on using the changeset viewer.