This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
203 lines (166 loc) · 8.9 KB
/
build.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- -->
<!-- JBoss, the OpenSource J2EE webOS -->
<!-- -->
<!-- Distributable under LGPL license. -->
<!-- See terms of license at http://www.gnu.org. -->
<!-- -->
<!-- ====================================================================== -->
<project>
<property name="hudson.dir" value="${basedir}"/>
<property name="hudson.target.dir" value="${hudson.dir}/target"/>
<!-- ================================================================== -->
<!-- Initialization for Jenkins -->
<!-- ================================================================== -->
<target name="init">
<!-- Check if ant.properties is available -->
<available property="ant.properties.available" file="${basedir}/ant.properties"/>
<fail message="Cannot find ant.properties. Did you copy/edit ant.properties.example?" unless="ant.properties.available"/>
<property file="${basedir}/ant.properties"/>
<xmlproperty file="${basedir}/pom.xml"/>
<property name="version.id" value="${project.version}"/>
<echo message="version.id=${version.id}"/>
</target>
<target name="init-jenkins" depends="init">
<property name="hudson.tomcat" value="${hudson.root}/jbossws-hudson-${version.id}/apache-tomcat"/>
<property name="hudson.home" value="${hudson.root}/jbossws-hudson-${version.id}/hudson-home"/>
<property name="hudson.scripts" value="${hudson.root}/jbossws-hudson-${version.id}/scripts"/>
<echo/>
<echo message="hudson.root = ${hudson.root}"/>
<echo message="hudson.home = ${hudson.home}"/>
<echo/>
<available file="${hudson.root}" property="hudson.root.available"/>
<available file="${hudson.tomcat}" property="hudson.tomcat.available"/>
<fail message="Hudson root not available" unless="hudson.root.available"/>
<property name="hudson.username.${hudson.username}" value="true"/>
<fail message="Cannot use default Jenkins username: ${hudson.username}" if="hudson.username.changeme"/>
<property name="hudson.password.${hudson.password}" value="true"/>
<fail message="Cannot use default Jenkins password: ${hudson.password}" if="hudson.password.changeme"/>
<property name="thirdparty.dir" value="${hudson.target.dir}/thirdparty"/>
<mkdir dir="${thirdparty.dir}"/>
</target>
<!--
Setup the Jenkins Tomcat instance
-->
<target name="jenkins-tomcat-setup" depends="init-jenkins" unless="hudson.tomcat.available">
<get src="http://archive.apache.org/dist/tomcat/tomcat-5/v${apache-tomcat}/bin/apache-tomcat-${apache-tomcat}.zip" dest="${thirdparty.dir}/apache-tomcat.zip" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/war/${jenkins-ver}/jenkins.war" dest="${thirdparty.dir}/jenkins.war" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/git/${git-plugin}/git.hpi" dest="${thirdparty.dir}/git.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/git-client/${git-client-plugin}/git-client.hpi" dest="${thirdparty.dir}/git-client.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/scm-api/${scm-api-plugin}/scm-api.hpi" dest="${thirdparty.dir}/scm-api.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/performance/${performance-plugin}/performance.hpi" dest="${thirdparty.dir}/performance.hpi" usetimestamp="true" verbose="true"/>
<mkdir dir="${hudson.root}"/>
<unzip src="${thirdparty.dir}/apache-tomcat.zip" dest="${hudson.root}"/>
<move file="${hudson.root}/apache-tomcat-${apache-tomcat}" tofile="${hudson.tomcat}"/>
<chmod perm="+x">
<fileset dir="${hudson.tomcat}/bin">
<include name="*.sh"/>
</fileset>
</chmod>
<!-- Configure Tomcat -->
<copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/jenkins.war"/>
<copy todir="${hudson.tomcat}" overwrite="true">
<fileset dir="${hudson.dir}/apache-tomcat">
<include name="**/*.xml"/>
</fileset>
<filterset>
<filtersfile file="${hudson.dir}/ant.properties"/>
<filter token="hudson.home" value="${hudson.home}"/>
</filterset>
</copy>
</target>
<!--
Update the Jenkins version
-->
<target name="jenkins-update" depends="init-jenkins">
<get src="https://updates.jenkins-ci.org/download/war/${jenkins-ver}/jenkins.war" dest="${thirdparty.dir}/jenkins.war" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/git/${git-plugin}/git.hpi" dest="${thirdparty.dir}/git.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/git-client/${git-client-plugin}/git-client.hpi" dest="${thirdparty.dir}/git-client.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/scm-api/${scm-api-plugin}/scm-api.hpi" dest="${thirdparty.dir}/scm-api.hpi" usetimestamp="true" verbose="true"/>
<get src="http://updates.jenkins-ci.org/download/plugins/performance/${performance-plugin}/performance.hpi" dest="${thirdparty.dir}/performance.hpi" usetimestamp="true" verbose="true"/>
<delete dir="${hudson.tomcat}/webapps/jenkins"/>
<copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/jenkins.war"/>
</target>
<!--
Setup the Jenkins QA environment
-->
<target name="jenkins-setup" depends="init-jenkins,jenkins-tomcat-setup"
description="Setup the Jenkins QA environment">
<!-- Configure Jenkins -->
<copy todir="${hudson.home}" overwrite="true">
<fileset dir="${hudson.dir}/hudson-home">
<include name="jobs/*/config.xml"/>
<include name="users/*/config.xml"/>
<include name="*.xml"/>
</fileset>
<filterset>
<filter token="hudson.home" value="${hudson.home}"/>
<filter token="version.id" value="${version.id}"/>
<filtersfile file="${hudson.dir}/ant.properties"/>
</filterset>
</copy>
<copy todir="${hudson.scripts}" overwrite="true">
<fileset dir="${hudson.dir}/scripts">
<include name="*"/>
</fileset>
</copy>
<chmod perm="+x">
<fileset dir="${hudson.scripts}">
<include name="*.sh"/>
</fileset>
</chmod>
<copy todir="${hudson.home}/plugins" overwrite="true">
<fileset dir="${thirdparty.dir}">
<include name="git.hpi"/>
</fileset>
</copy>
<copy todir="${hudson.home}/plugins" overwrite="true">
<fileset dir="${thirdparty.dir}">
<include name="git-client.hpi"/>
</fileset>
</copy>
<copy todir="${hudson.home}/plugins" overwrite="true">
<fileset dir="${thirdparty.dir}">
<include name="scm-api.hpi"/>
</fileset>
</copy>
<copy todir="${hudson.home}/plugins" overwrite="true">
<fileset dir="${thirdparty.dir}">
<include name="performance.hpi"/>
</fileset>
</copy>
<echo/>
<echo message="*************************************"/>
<echo message="* Jenkins setup successfully *"/>
<echo message="* ant jenkins-start *"/>
<echo message="*************************************"/>
<echo/>
</target>
<target name="jenkins-stop" depends="init-jenkins" description="Stops the Jenkins QA environment">
<exec executable="${hudson.tomcat}/bin/catalina.sh" failonerror="true">
<arg line="stop"/>
</exec>
<echo/>
<echo message="*************************************"/>
<echo message="* Jenkins stopped successfully *"/>
<echo message="* ant jenkins-start *"/>
<echo message="*************************************"/>
<echo/>
</target>
<target name="jenkins-start" depends="init-jenkins" description="Start the Jenkins QA environment">
<property environment="env"/>
<fail message="unset JBOSS_REPOSITORY=${env.JBOSS_REPOSITORY}" if="env.JBOSS_REPOSITORY"/>
<exec executable="${hudson.tomcat}/bin/catalina.sh" failonerror="true" output="${hudson.target.dir}/hudson.log">
<env key="CATALINA_OPTS" value="-Xmx1280m -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"/>
<env key="HUDSON_HOME" value="${hudson.home}"/>
<arg line="start"/>
</exec>
<echo/>
<echo message="*************************************"/>
<echo message="* Jenkins started successfully *"/>
<echo message="* http://localhost:${hudson.http.port}/jenkins *"/>
<echo message="*************************************"/>
<echo/>
</target>
</project>