source: Jenkins/Distribute @ 6b293bd

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

Like Cforall, groovy does not support tuple assign and tuple declaration in the same statement.

  • 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
29                        (commit, build) = prepare_build()
30
31                        node('x64') {
32                                BuildDir  = pwd tmp: true
33                                SrcDir    = pwd tmp: false
34
35                                Tools.Clean()
36
37                                Tools.Checkout( commit )
38
39                                final version = GetVersion( build )
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
50        // catch (Exception caughtError) {
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()
61        // }
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//===========================================================================================================
79def GetVersion(build) {
80        final pver = "sed 's/AC_INIT(\[cfa-cc\],\[\(.*\)\],\[cforall@plg.uwaterloo.ca\])/\1/;t;d' ${SrcDir} configure.ac"
81        final version = "${pver}.${build}"
82
83        echo "Package Version: ${pver}"
84        echo "Build   Version: ${build}"
85        echo "Long    Version: ${version}"
86
87        return version
88}
89
90
91//===========================================================================================================
92// Helper classes/variables/routines
93//===========================================================================================================
94def prepare_build() {
95        // prepare the properties
96        properties ([                                                                                                   \
97                buildDiscarder(logRotator(                                                                              \
98                        artifactDaysToKeepStr: '',                                                                      \
99                        artifactNumToKeepStr: '',                                                                       \
100                        daysToKeepStr: '730',                                                                           \
101                        numToKeepStr: '1000'                                                                            \
102                )),                                                                                                             \
103                [$class: 'ParametersDefinitionProperty',                                                                \
104                        parameterDefinitions: [                                                                         \
105                                [$class: 'StringParameterDefinition',                                           \
106                                        description: 'The git commit to checkout',                              \
107                                        name: 'GitRef',                                                                 \
108                                        defaultValue: '',                                                               \
109                                ],                                                                                              \
110                                [$class: 'StringParameterDefinition',                                           \
111                                        description: 'Build Number to put into the version',                    \
112                                        name: 'Build',                                                                  \
113                                        defaultValue: '0',                                                              \
114                                ],                                                                                              \
115                        ],
116                ]])
117
118        // It's unfortunate but it looks like we need to checkout the entire repo just to get
119        // - the pretty git printer
120        // - Jenkins.tools
121        checkout scm
122
123        Tools = load "Jenkins/tools.groovy"
124
125        currentBuild.description = "Distributing Tarball"
126        def ref = params.GitRef ? params.GitRef : "HEAD"
127        echo "Distributing git commit ${ref}"
128
129        return [params.GitRef, params.Build]
130}
131
Note: See TracBrowser for help on using the repository browser.