1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
A utility ant script get the base builder from CVS.
Hudson jobs can call this script from ant
as one of it first build steps.
-->
<project
name="getBaseBuilder"
default="getBaseBuilder"
basedir=".">
<target
name="hudson-init"
if="hudson"
depends="checkHudson">
<!-- as of this writing, 04/22/2012, this was current list of
hudson provided variables. We take advantage of a number
of them, but "translate" them into our own variable names,
for a little loser build-system seperattion
BUILD_NUMBER
The current build number, such as "153"
BUILD_ID
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
JOB_NAME
Name of the project of this build, such as "foo"
BUILD_TAG
String of "hudson-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
EXECUTOR_NUMBER
The unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
NODE_NAME
Name of the slave if the build is on a slave, or "" if run on master
NODE_LABELS
Whitespace-separated list of labels that the node is assigned.
JAVA_HOME
If your job is configured to use a specific JDK, this variable is set to the JAVA_HOME of the specified JDK. When this variable is set, PATH is also updated to have $JAVA_HOME/bin.
WORKSPACE
The absolute path of the workspace.
HUDSON_URL
Full URL of Hudson, like http://server:port/hudson/
BUILD_URL
Full URL of this build, like http://server:port/hudson/job/foo/15/
JOB_URL
Full URL of this job, like http://server:port/hudson/job/foo/
SVN_REVISION
For Subversion-based projects, this variable contains the revision number of the module.
CVS_BRANCH
For CVS-based projects, this variable contains the branch of the module. If CVS is configured to check out the trunk, this environment variable will not be set.
HUDSON_USER
Currently logged in user
-->
<property environment="hudson" />
<property
name="WORKSPACE"
value="${hudson.WORKSPACE}" />
<!--
<property
name="BUILD_ID"
value="${hudson.BUILD_ID}" />
<property
name="BUILD_NUMBER"
value="${hudson.BUILD_NUMBER}" />
<property
name="JOB_NAME"
value="${hudson.JOB_NAME}" />
-->
</target>
<target
name="init"
depends="hudson-init"
unless="getBaseBuilderInitialized">
<!-- assign defaults if not on hudson, for local testing if nothing else -->
<property
name="WORKSPACE"
value="${basedir}" />
<property
name="builderVersion"
value="R38M6PlusRC3G" />
<property
name="cvsRoot"
value=":pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse" />
<property
name="cvsProject"
value="org.eclipse.releng.basebuilder" />
<!-- the desired folder name (made to stay consistent with cvs module name, though Git project
is named eclipse.platform.releng.basebuilder fil-->
<property
name="folderName"
value="org.eclipse.releng.basebuilder" />
<condition property="fetchSource" value="git">
<not>
<isset property="basebuilderlocal" />
</not>
</condition>
<echo message="hudson: ${hudson}" />
<echo message="WORKSPACE: ${WORKSPACE}" />
<echo message="basebuilder version: ${builderVersion}" />
<echo message="cvsRoot: ${cvsRoot}" />
<echo message="cvsProject: ${cvsProject}" />
<echo message="fetchSource: ${fetchSource}" />
<!-- leave useGit undefined to imply to use CVS. Callers can override git defaults with -DfetchSource=cvs
or, anything besides 'git' implies cvs.
-->
<condition
property="useGit"
value="true">
<equals
arg1="${fetchSource}"
arg2="git"
casesensitive="false"
trim="true" />
</condition>
<echo message="useGit: ${useGit}" />
<!-- don't need? yet
<echo message="BUILD_ID: ${BUILD_ID}" />
<echo message="BUILD_NUMBER: ${BUILD_NUMBER}" />
<echo message="JOB_NAME: ${JOB_NAME}" />
<echo message="buildId: ${buildId}" />
-->
<!-- not used? But, may want in future?
<condition
property="buildcleanarg"
value="-Dbuild.clean=${build.clean}"
else="">
<isset property="build.clean" />
</condition>
<condition
property="buildercleanarg"
value="-Dcheckout.builder.clean=${checkout.builder.clean}"
else="">
<isset property="checkout.builder.clean" />
</condition>
-->
<property
name="getBaseBuilderInitialized"
value="true" />
</target>
<target
name="getBaseBuilder"
depends="checkHudson, init">
<fail
unless="builderVersion"
message="This script needs builderVersion to run" />
<!-- remove old one, if there, and make sure one exists for eventual checkout/copy/globmapper -->
<delete dir="${WORKSPACE}/${folderName}" />
<mkdir dir="${WORKSPACE}/${folderName}" />
<antcall target="fetchBaseBuilder" />
<antcall target="fetchBaseBuilderLocal" />
</target>
<!-- hurestic to check if we are running on hudson variable, if so -->
<target name="checkHudson">
<!-- HUDSON_USER should just be "anonyous" for most of our cases (currently)
but seems a safe variable to check ... if set, assume we are on hudson,
if not set, assume we are not and leave "hudson" unset (not false)
Hmm, seems HUDSON_USER is not reliably set. The only 4 I saw reliably
set were
[echoproperties] env.HUDSON_COOKIE
[echoproperties] env.HUDSON_HOME
[echoproperties] env.HUDSON_SERVER_COOKIE
[echoproperties] env.HUDSON_URL
Not sure which would be best/safest to use in huristic, but
I'll go with URL for now.
-->
<property environment="env" />
<condition property="hudson">
<isset property="env.HUDSON_URL" />
</condition>
</target>
<target
name="fetchBaseBuilderFromGit"
depends="init"
if="useGit">
<echo message="Fetching basebuilder from Git via CGit" />
<get
src="http://git.eclipse.org/c/platform/eclipse.platform.releng.basebuilder.git/snapshot/eclipse.platform.releng.basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}/basebuilder-${builderVersion}.zip" />
<unzip
src="${WORKSPACE}/basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}"
overwrite="true" />
<move todir="${WORKSPACE}/${folderName}">
<fileset dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}">
<include name="**/*" />
</fileset>
</move>
<chmod perm="ugo+x">
<fileset dir="${WORKSPACE}/${folderName}">
<include name="eclipse" />
<include name="*.so*" />
</fileset>
</chmod>
<!-- we've moved the files, now to remove the empty dir -->
<delete dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}" />
<!-- not sure why I couldn't get globmapper to work here with unzip?
<globmapper
from="eclipse.platform.releng.basebuilder-${builderVersion}/*"
to="${folderName}/*" />
-->
<!-- cleanup (may eventually want to "cache" this zip file, so no need to re-fetch if already exists
temp leave to save a copy
<delete file="${WORKSPACE}/basebuilder-${builderVersion}.zip" />
-->
</target>
<target
name="fetchBaseBuilderFromCVS"
depends="init"
unless="useGit">
<echo message="Fetching basebuilder from CVS" />
<cvs
cvsroot="${cvsRoot}"
command="export"
quiet="true"
dest="${WORKSPACE}"
tag="${builderVersion}"
package="${cvsProject}">
</cvs>
</target>
<target
name="fetchBaseBuilder"
depends="init, fetchBaseBuilderFromCVS, fetchBaseBuilderFromGit"
unless="basebuilderlocal">
<echo message="Fetched basebuilder to ${WORKSPACE}/${folderName}" />
</target>
<target
name="fetchBaseBuilderLocal"
depends="init"
if="basebuilderlocal">
<unzip
src="${basebuilderlocal}/basebuilder-${builderVersion}.zip"
dest="${WORKSPACE}"
overwrite="true" />
<move todir="${WORKSPACE}/${folderName}">
<fileset dir="${WORKSPACE}/eclipse.platform.releng.basebuilder-${builderVersion}">
<include name="**/*" />
</fileset>
</move>
<chmod perm="ugo+x">
<fileset dir="${WORKSPACE}/${folderName}">
<include name="eclipse" />
<include name="*.so*" />
</fileset>
</chmod>
<echo message="Copied basebuilder to ${WORKSPACE}/${folderName}" />
</target>
</project>
|