source: Jenkins/Distribute @ 8fe6040

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 8fe6040 was 8fe6040, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Distribute now prints the version

  • Property mode set to 100644
File size: 3.5 KB
Line 
1#!groovy
2
3import groovy.transform.Field
4
5// For skipping stages
6import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
7
8//===========================================================================================================
9// Main loop of the compilation
10//===========================================================================================================
11
12node('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
28                        final (commit, build) = prepare_build()
29
30                        node('x64') {
31                                BuildDir  = pwd tmp: true
32                                SrcDir    = pwd tmp: false
33
34                                Tools.Clean()
35
36                                Tools.Checkout( commit )
37
38                                final version = GetVersion( build )
39                        }
40
41                        // Update the build directories when exiting the node
42                        BuildDir  = pwd tmp: true
43                        SrcDir    = pwd tmp: false
44                }
45        }
46
47        //If an exception is caught we need to change the status and remember to
48        //attach the build log to the email
49        // catch (Exception caughtError) {
50                // //rethrow error later
51                // err = caughtError
52
53                // echo err.toString()
54
55                // //An error has occured, the build log is relevent
56                // log_needed = true
57
58                // //Store the result of the build log
59                // currentBuild.result = "${StageName} FAILURE".trim()
60        // }
61
62        finally {
63                // //Send email with final results if this is not a full build
64                // email(log_needed)
65
66                // echo 'Distribution Completed'
67
68                // /* Must re-throw exception to propagate error */
69                // if (err) {
70                //      throw err
71                // }
72        }
73}
74
75//===========================================================================================================
76// Main compilation routines
77//===========================================================================================================
78def GetVersion(build) {
79        final pver = "sed 's/AC_INIT(\[cfa-cc\],\[\(.*\)\],\[cforall@plg.uwaterloo.ca\])/\1/;t;d' ${SrcDir} configure.ac"
80        final version = "${pver}.${build}"
81
82        echo "Package Version: ${pver}"
83        echo "Build   Version: ${build}"
84        echo "Long    Version: ${version}"
85
86        return version
87}
88
89
90//===========================================================================================================
91// Helper classes/variables/routines
92//===========================================================================================================
93def prepare_build() {
94        // prepare the properties
95        properties ([                                                                                                   \
96                buildDiscarder(logRotator(                                                                              \
97                        artifactDaysToKeepStr: '',                                                                      \
98                        artifactNumToKeepStr: '',                                                                       \
99                        daysToKeepStr: '730',                                                                           \
100                        numToKeepStr: '1000'                                                                            \
101                )),                                                                                                             \
102                [$class: 'ParametersDefinitionProperty',                                                                \
103                        parameterDefinitions: [                                                                         \
104                                [$class: 'StringParameterDefinition',                                           \
105                                        description: 'The git commit to checkout',                              \
106                                        name: 'GitRef',                                                                 \
107                                        defaultValue: '',                                                               \
108                                ],                                                                                              \
109                                [$class: 'StringParameterDefinition',                                           \
110                                        description: 'Build Number to put into the version',                    \
111                                        name: 'Build',                                                                  \
112                                        defaultValue: '0',                                                              \
113                                ],                                                                                              \
114                        ],
115                ]])
116
117        // It's unfortunate but it looks like we need to checkout the entire repo just to get
118        // - the pretty git printer
119        // - Jenkins.tools
120        checkout scm
121
122        Tools = load "Jenkins/tools.groovy"
123
124        currentBuild.description = "Distributing Tarball"
125        def ref = params.GitRef ? params.GitRef : "HEAD"
126        echo "Distributing git commit ${ref}"
127
128        return [params.GitRef, params.Build]
129}
130
Note: See TracBrowser for help on using the repository browser.