source: Jenkins/Distribute

Last change on this file was 0a10dc8, checked in by Peter A. Buhr <pabuhr@…>, 9 days ago

update groovy scripts to suppress warning messages

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