[4011b98] | 1 | #!groovy
|
---|
| 2 |
|
---|
| 3 | import groovy.transform.Field
|
---|
| 4 |
|
---|
| 5 | // For skipping stages
|
---|
| 6 | import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
|
---|
| 7 |
|
---|
| 8 | //===========================================================================================================
|
---|
| 9 | // Main loop of the compilation
|
---|
| 10 | //===========================================================================================================
|
---|
| 11 |
|
---|
| 12 | node('master') {
|
---|
| 13 | // Globals
|
---|
| 14 | BuildDir = pwd tmp: true
|
---|
| 15 | SrcDir = pwd tmp: false
|
---|
| 16 | Settings = null
|
---|
| 17 |
|
---|
| 18 | // Local variables
|
---|
| 19 | def err = null
|
---|
| 20 | def log_needed = false
|
---|
| 21 |
|
---|
| 22 | currentBuild.result = "SUCCESS"
|
---|
| 23 |
|
---|
| 24 | try {
|
---|
| 25 | //Wrap build to add timestamp to command line
|
---|
| 26 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
| 27 |
|
---|
[6b293bd] | 28 | final commit, build
|
---|
| 29 | (commit, build) = prepare_build()
|
---|
[4011b98] | 30 |
|
---|
| 31 | node('x64') {
|
---|
| 32 | BuildDir = pwd tmp: true
|
---|
| 33 | SrcDir = pwd tmp: false
|
---|
| 34 |
|
---|
[6c9e0bc] | 35 | Tools.Clean()
|
---|
[4011b98] | 36 |
|
---|
[6c9e0bc] | 37 | Tools.Checkout( commit )
|
---|
[8fe6040] | 38 |
|
---|
| 39 | final version = GetVersion( build )
|
---|
[4011b98] | 40 | }
|
---|
| 41 |
|
---|
| 42 | // Update the build directories when exiting the node
|
---|
| 43 | BuildDir = pwd tmp: true
|
---|
| 44 | SrcDir = pwd tmp: false
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | //If an exception is caught we need to change the status and remember to
|
---|
| 49 | //attach the build log to the email
|
---|
[cf2257f] | 50 | // catch (Exception caughtError) {
|
---|
[4011b98] | 51 | // //rethrow error later
|
---|
| 52 | // err = caughtError
|
---|
| 53 |
|
---|
| 54 | // echo err.toString()
|
---|
| 55 |
|
---|
| 56 | // //An error has occured, the build log is relevent
|
---|
| 57 | // log_needed = true
|
---|
| 58 |
|
---|
| 59 | // //Store the result of the build log
|
---|
| 60 | // currentBuild.result = "${StageName} FAILURE".trim()
|
---|
[cf2257f] | 61 | // }
|
---|
[4011b98] | 62 |
|
---|
| 63 | finally {
|
---|
| 64 | // //Send email with final results if this is not a full build
|
---|
| 65 | // email(log_needed)
|
---|
| 66 |
|
---|
| 67 | // echo 'Distribution Completed'
|
---|
| 68 |
|
---|
| 69 | // /* Must re-throw exception to propagate error */
|
---|
| 70 | // if (err) {
|
---|
| 71 | // throw err
|
---|
| 72 | // }
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | //===========================================================================================================
|
---|
| 77 | // Main compilation routines
|
---|
| 78 | //===========================================================================================================
|
---|
[8fe6040] | 79 | def GetVersion(build) {
|
---|
[7e366bd] | 80 | final pver = sh(
|
---|
| 81 | returnStdout: true,
|
---|
[ad915e0] | 82 | script: "sed 's/AC_INIT(\\[cfa-cc\\],\\[\\(.*\\)\\],\\[cforall@plg.uwaterloo.ca\\])/\\1/;t;d' ${SrcDir}/configure.ac"
|
---|
[7e366bd] | 83 | ).trim()
|
---|
| 84 |
|
---|
[8fe6040] | 85 | final version = "${pver}.${build}"
|
---|
[f78ead5] | 86 |
|
---|
[8fe6040] | 87 | echo "Package Version: ${pver}"
|
---|
| 88 | echo "Build Version: ${build}"
|
---|
| 89 | echo "Long Version: ${version}"
|
---|
[4011b98] | 90 |
|
---|
[8fe6040] | 91 | return version
|
---|
| 92 | }
|
---|
[4011b98] | 93 |
|
---|
| 94 |
|
---|
| 95 | //===========================================================================================================
|
---|
| 96 | // Helper classes/variables/routines
|
---|
| 97 | //===========================================================================================================
|
---|
| 98 | def prepare_build() {
|
---|
| 99 | // prepare the properties
|
---|
| 100 | properties ([ \
|
---|
| 101 | buildDiscarder(logRotator( \
|
---|
| 102 | artifactDaysToKeepStr: '', \
|
---|
| 103 | artifactNumToKeepStr: '', \
|
---|
| 104 | daysToKeepStr: '730', \
|
---|
| 105 | numToKeepStr: '1000' \
|
---|
| 106 | )), \
|
---|
| 107 | [$class: 'ParametersDefinitionProperty', \
|
---|
| 108 | parameterDefinitions: [ \
|
---|
[782d479] | 109 | [$class: 'StringParameterDefinition', \
|
---|
[c3d3c22] | 110 | description: 'The git commit to checkout', \
|
---|
| 111 | name: 'GitRef', \
|
---|
[782d479] | 112 | defaultValue: '', \
|
---|
[4011b98] | 113 | ], \
|
---|
[8fe6040] | 114 | [$class: 'StringParameterDefinition', \
|
---|
| 115 | description: 'Build Number to put into the version', \
|
---|
| 116 | name: 'Build', \
|
---|
| 117 | defaultValue: '0', \
|
---|
| 118 | ], \
|
---|
[4011b98] | 119 | ],
|
---|
| 120 | ]])
|
---|
| 121 |
|
---|
[4b138dd] | 122 | // It's unfortunate but it looks like we need to checkout the entire repo just to get
|
---|
| 123 | // - the pretty git printer
|
---|
| 124 | // - Jenkins.tools
|
---|
| 125 | checkout scm
|
---|
| 126 |
|
---|
| 127 | Tools = load "Jenkins/tools.groovy"
|
---|
| 128 |
|
---|
[c3d3c22] | 129 | currentBuild.description = "Distributing Tarball"
|
---|
| 130 | def ref = params.GitRef ? params.GitRef : "HEAD"
|
---|
| 131 | echo "Distributing git commit ${ref}"
|
---|
[f78ead5] | 132 |
|
---|
[8fe6040] | 133 | return [params.GitRef, params.Build]
|
---|
[6855d14] | 134 | }
|
---|
[4011b98] | 135 |
|
---|