Changes in Jenkinsfile [e11957e:abc2a643]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Jenkinsfile
re11957e rabc2a643 2 2 3 3 import groovy.transform.Field 4 5 // For skipping stages6 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils7 4 8 5 //=========================================================================================================== … … 15 12 SrcDir = pwd tmp: false 16 13 Settings = null 17 StageName = ''14 Tools = null 18 15 19 16 // Local variables … … 33 30 SrcDir = pwd tmp: false 34 31 35 clean()36 37 checkout()32 Tools.Clean() 33 34 Tools.Checkout() 38 35 39 36 build() … … 57 54 //attach the build log to the email 58 55 catch (Exception caughtError) { 59 //rethrow error later 56 // Store the result of the build log 57 currentBuild.result = "FAILURE" 58 59 // An error has occured, the build log is relevent 60 log_needed = true 61 62 // rethrow error later 60 63 err = caughtError 61 64 65 // print the error so it shows in the log 62 66 echo err.toString() 63 64 //An error has occured, the build log is relevent65 log_needed = true66 67 //Store the result of the build log68 currentBuild.result = "${StageName} FAILURE".trim()69 67 } 70 68 … … 84 82 // Main compilation routines 85 83 //=========================================================================================================== 86 def clean() {87 build_stage('Cleanup', true) {88 // clean the build by wipping the build directory89 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 loop96 def checkout() {97 build_stage('Checkout', true) {98 //checkout the source code and clean the repo99 final scmVars = checkout scm100 Settings.GitNewRef = scmVars.GIT_COMMIT101 Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT102 103 echo GitLogMessage()104 105 // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles106 // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles107 // and these cause more problems.108 sh 'find . -name Makefile.in -exec touch {} +'109 }110 }111 112 84 def build() { 113 85 debug = true 114 86 release = Settings.RunAllTests || Settings.RunBenchmark 115 build_stage('Build : configure', true) { 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 116 94 // Build outside of the src tree to ease cleaning 117 95 dir (BuildDir) { 118 //Configure the co npilation (Output is not relevant)96 //Configure the compilation (Output is not relevant) 119 97 //Use the current directory as the installation target so nothing escapes the sandbox 120 98 //Also specify the compiler by hand … … 126 104 } 127 105 128 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet" 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}" 129 109 130 110 // Configure libcfa … … 133 113 } 134 114 135 build_stage('Build : cfa-cpp', true) {115 Tools.BuildStage('Build : cfa-cpp', true) { 136 116 // Build outside of the src tree to ease cleaning 137 117 dir (BuildDir) { … … 144 124 } 145 125 146 build_stage('Build : libcfa(debug)', debug) {126 Tools.BuildStage('Build : libcfa(debug)', debug) { 147 127 // Build outside of the src tree to ease cleaning 148 128 dir (BuildDir) { … … 151 131 } 152 132 153 build_stage('Build : libcfa(nodebug)', release) {133 Tools.BuildStage('Build : libcfa(nodebug)', release) { 154 134 // Build outside of the src tree to ease cleaning 155 135 dir (BuildDir) { 156 136 sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug" 137 } 138 } 139 140 Tools.BuildStage('Build : install', true) { 141 // Build outside of the src tree to ease cleaning 142 dir (BuildDir) { 143 sh "make -j 8 --no-print-directory install" 157 144 } 158 145 } … … 161 148 def test() { 162 149 try { 163 build_stage('Test: short', !Settings.RunAllTests) {150 Tools.BuildStage('Test: short', !Settings.RunAllTests) { 164 151 dir (BuildDir) { 165 152 //Run the tests from the tests directory … … 168 155 } 169 156 170 build_stage('Test: full', Settings.RunAllTests) {157 Tools.BuildStage('Test: full', Settings.RunAllTests) { 171 158 dir (BuildDir) { 172 159 //Run the tests from the tests directory … … 179 166 echo "Archiving core dumps" 180 167 dir (BuildDir) { 181 archiveArtifacts artifacts: "tests/crashes/**/* ", fingerprint: true168 archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true 182 169 } 183 170 throw err … … 186 173 187 174 def benchmark() { 188 build_stage('Benchmark', Settings.RunBenchmark) {175 Tools.BuildStage('Benchmark', Settings.RunBenchmark) { 189 176 dir (BuildDir) { 190 177 //Append bench results … … 195 182 196 183 def build_doc() { 197 build_stage('Documentation', Settings.BuildDocumentation) {184 Tools.BuildStage('Documentation', Settings.BuildDocumentation) { 198 185 dir ('doc/user') { 199 186 make_doc() … … 207 194 208 195 def publish() { 209 build_stage('Publish', true) {196 Tools.BuildStage('Publish', true) { 210 197 211 198 if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' } … … 215 202 216 203 //Then publish the results 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, 's ignal', groupConcurrency, false, 'Internal and External Scheduling')224 do_plot(Settings.RunBenchmark && Settings.Publish, 's ignal.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')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, 'scheduling' , groupConcurrency, false, 'Internal and External Scheduling') 211 do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)') 225 212 } 226 213 } … … 229 216 //Routine responsible of sending the email notification once the build is completed 230 217 //=========================================================================================================== 231 @NonCPS232 def SplitLines(String text) {233 def list = []234 235 text.eachLine {236 list += it237 }238 239 return list240 }241 242 def GitLogMessage() {243 if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"244 245 def oldRef = Settings.GitOldRef246 def newRef = Settings.GitNewRef247 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 = oldRef258 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 294 218 //Standard build email notification 295 219 def email(boolean log) { … … 303 227 generated because of a git hooks/post-receive script following 304 228 a ref change which was pushed to the C\u2200 repository.</p> 305 """ + GitLogMessage()229 """ + Tools.GitLogMessage() 306 230 307 231 def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca" … … 325 249 public String CXX 326 250 public String CC 327 328 CC_Desc(String name, String CXX, String CC) { 251 public String lto 252 253 CC_Desc(String name, String CXX, String CC, String lto) { 329 254 this.name = name 330 255 this.CXX = CXX 331 this.CC = CC 256 this.CC = CC 257 this.lto = lto 332 258 } 333 259 } … … 349 275 public final CC_Desc Compiler 350 276 public final Arch_Desc Architecture 277 public final Boolean NewAST 351 278 public final Boolean RunAllTests 352 279 public final Boolean RunBenchmark … … 364 291 switch( param.Compiler ) { 365 292 case 'gcc-9': 366 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9' )293 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto') 367 294 break 368 295 case 'gcc-8': 369 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8' )296 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto') 370 297 break 371 298 case 'gcc-7': 372 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7' )299 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto') 373 300 break 374 301 case 'gcc-6': 375 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6' )302 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto') 376 303 break 377 304 case 'gcc-5': 378 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5' )305 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto') 379 306 break 380 307 case 'gcc-4.9': 381 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9' )308 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto') 382 309 break 383 310 case 'clang': 384 this.Compiler = new CC_Desc('clang', 'clang++- 6.0', 'gcc-6')311 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0') 385 312 break 386 313 default : … … 400 327 401 328 this.IsSandbox = (branch == "jenkins-sandbox") 329 this.NewAST = param.NewAST 402 330 this.RunAllTests = param.RunAllTests 403 331 this.RunBenchmark = param.RunBenchmark … … 409 337 this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}" 410 338 339 final ast = this.NewAST ? "New AST" : "Old AST" 411 340 this.DescLong = """Compiler : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC }) 341 AST Version : ${ ast.toString() } 412 342 Architecture : ${ this.Architecture.name } 413 343 Arc Flags : ${ this.Architecture.flags } … … 439 369 // prepare the properties 440 370 properties ([ \ 371 buildDiscarder(logRotator( \ 372 artifactDaysToKeepStr: '', \ 373 artifactNumToKeepStr: '', \ 374 daysToKeepStr: '730', \ 375 numToKeepStr: '1000' \ 376 )), \ 441 377 [$class: 'ParametersDefinitionProperty', \ 442 378 parameterDefinitions: [ \ … … 444 380 description: 'Which compiler to use', \ 445 381 name: 'Compiler', \ 446 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', 382 choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \ 447 383 defaultValue: 'gcc-8', \ 448 384 ], \ … … 454 390 ], \ 455 391 [$class: 'BooleanParameterDefinition', \ 392 description: 'If true, build compiler using new AST', \ 393 name: 'NewAST', \ 394 defaultValue: true, \ 395 ], \ 396 [$class: 'BooleanParameterDefinition', \ 456 397 description: 'If false, only the quick test suite is ran', \ 457 398 name: 'RunAllTests', \ … … 481 422 ]]) 482 423 483 // It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer 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 484 427 checkout scm 428 429 Tools = load "Jenkins/tools.groovy" 485 430 486 431 final settings = new BuildSettings(params, env.BRANCH_NAME) … … 490 435 491 436 return settings 492 }493 494 def build_stage(String name, boolean run, Closure block ) {495 StageName = name496 echo " -------- ${StageName} -------- "497 if(run) {498 stage(name, block)499 } else {500 stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }501 }502 437 } 503 438
Note: See TracChangeset
for help on using the changeset viewer.