source: Jenkins/Distribute@ 06ffa95

Last change on this file since 06ffa95 was e018546, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

More work into not using master node

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