source: Jenkins/Distribute@ dde7d6d

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since dde7d6d was dde7d6d, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

I still don't understand globals in groovy.

  • Property mode set to 100644
File size: 4.0 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 Version = ''
18
19 // Local variables
20 def err = null
21 def log_needed = false
22
23 currentBuild.result = "SUCCESS"
24
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 Version = GetVersion( build )
40
41 Configure()
42
43 Package()
44
45 Test()
46
47 Archive()
48 }
49
50 // Update the build directories when exiting the node
51 BuildDir = pwd tmp: true
52 SrcDir = pwd tmp: false
53 }
54
55}
56
57//===========================================================================================================
58// Main compilation routines
59//===========================================================================================================
60def GetVersion(build) {
61 final pver = sh(
62 returnStdout: true,
63 script: "sed 's/AC_INIT(\\[cfa-cc\\],\\[\\(.*\\)\\],\\[cforall@plg.uwaterloo.ca\\])/\\1/;t;d' ${SrcDir}/configure.ac"
64 ).trim()
65
66 final version = "${pver}.${build}"
67
68 echo "Package Version: ${pver}"
69 echo "Build Version: ${build}"
70 echo "Long Version: ${version}"
71
72 return version
73}
74
75def Configure() {
76 Tools.BuildStage('Configure', true) {
77 // Configure must be run inside the tree
78 dir (SrcDir) {
79 // Generate the necessary build files
80 sh './autogen.sh'
81 }
82
83 // Build outside of the src tree to ease cleaning
84 dir (BuildDir) {
85 // Configure the compilation (Output is not relevant)
86 // Use the current directory as the installation target so nothing escapes the sandbox
87 // Also specify the compiler by hand
88 sh "${SrcDir}/configure CXX=g++-9 CC=gcc-9 AR=gcc-ar RANLIB=gcc-ranlib --quiet"
89
90 // Configure libcfa
91 sh 'make -j 8 --no-print-directory configure-libcfa'
92 }
93 }
94}
95
96def Package() {
97 Tools.BuildStage('Package', true) {
98 dir (BuildDir) {
99 sh "make VERSION=${Version} dist"
100 }
101 }
102}
103
104def Test() {
105 Tools.BuildStage('Package', true) {
106 dir (BuildDir) {
107 sh "make VERSION=${Version} distcheck -j 8"
108 }
109 }
110}
111
112def Archive() {
113 dir (BuildDir) {
114 archiveArtifacts artifacts: "cfa-cc-*.tar.gz", fingerprint: true
115 }
116}
117
118
119//===========================================================================================================
120// Helper classes/variables/routines
121//===========================================================================================================
122def prepare_build() {
123 // prepare the properties
124 properties ([ \
125 buildDiscarder(logRotator( \
126 artifactDaysToKeepStr: '', \
127 artifactNumToKeepStr: '', \
128 daysToKeepStr: '730', \
129 numToKeepStr: '1000' \
130 )), \
131 [$class: 'ParametersDefinitionProperty', \
132 parameterDefinitions: [ \
133 [$class: 'StringParameterDefinition', \
134 description: 'The git commit to checkout', \
135 name: 'GitRef', \
136 defaultValue: '', \
137 ], \
138 [$class: 'StringParameterDefinition', \
139 description: 'Build Number to put into the version', \
140 name: 'Build', \
141 defaultValue: '0', \
142 ], \
143 ],
144 ]])
145
146 // It's unfortunate but it looks like we need to checkout the entire repo just to get
147 // - the pretty git printer
148 // - Jenkins.tools
149 checkout scm
150
151 Tools = load "Jenkins/tools.groovy"
152
153 currentBuild.description = "Distributing Tarball"
154 def ref = params.GitRef ? params.GitRef : "HEAD"
155 echo "Distributing git commit ${ref}"
156
157 return [params.GitRef, params.Build]
158}
159
Note: See TracBrowser for help on using the repository browser.