forked from SoftwareAG/sagdevops-ci-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildDeployer.xml
129 lines (106 loc) · 5.3 KB
/
buildDeployer.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
<?xml version="1.0"?>
<!--
Copyright © 2018 Software AG, Darmstadt, Germany and/or its licensors
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-->
<project name="Deploy" default="deployWM" basedir=".">
<!-- Global Variables that concern the code and should be changed only if the code is changed -->
<!-- Template for the Deployer Project Specification -->
<property name="deployerProjectDefinitionTemplate" value="resources/ProjectSpecificationTemplate.xml"/>
<!-- Target filename of the Deployer Project Specification for this run -->
<property name="deployerProjectDefinition" value="${workspace.dir}/ProjectAutomator/${projectName}DeploymentSpec.xml"/>
<!-- XSLT for the Deployer Project Specification - adding Repository and Project Sections -->
<property name="initialXSLT" value="resources/setUpInitial.xslt"/>
<target name="deployWM" description="main deploy task" depends="startDeployment, initPAandDeployerWindows, initPAandDeployerUnix, createDeployerSpec,execProjectAutomator,triggerDeploy">
</target>
<target name="startDeployment">
<echo message="Start deploying ${projectName}" />
</target>
<!-- determine which PA and Deployer executables are used - different for Windows and Unix -->
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<target name="initPAandDeployerWindows" if="isWindows">
<property name="deployerExecutable" value="Deployer.bat" />
<property name="deployerAutomatorExecutable" value="projectautomator.bat" />
</target>
<target name="initPAandDeployerUnix" if="isUnix">
<property name="deployerExecutable" value="Deployer.sh" />
<property name="deployerAutomatorExecutable" value="projectautomatorUnix.sh" />
</target>
<!-- determine which PA and Deployer executables are used - different for Windows and Unix -->
<target name="createDeployerSpec" depends="cleanupDeployerSpec,setupDeployerSpec">
</target>
<target name="cleanupDeployerSpec">
<if>
<available file="${deployerProjectDefinition}"/>
<then>
<delete file="${deployerProjectDefinition}"/>
</then>
</if>
</target>
<target name="setupDeployerSpec" description="Creates the project automator xml with XSLT based on the given variables.">
<xslt style="${initialXSLT}" in="${deployerProjectDefinitionTemplate}" out="${deployerProjectDefinition}">
<!--build/deployer server props -->
<param name="deployerHost" expression="${deployerHost}" />
<param name="deployerPort" expression="${deployerPort}" />
<param name="deployerUsername" expression="${deployerUsername}" />
<param name="deployerPassword" expression="${deployerPassword}" />
<!--target server props -->
<param name="testISHost" expression="${testISHost}" />
<param name="testISPort" expression="${testISPort}" />
<param name="testISUsername" expression="${testISUsername}" />
<param name="testISPassword" expression="${testISPassword}" />
<!-- general props -->
<param name="repoName" expression="${repositoryName}" />
<param name="repoPath" expression="${buildOutputDir}" />
<param name="projectName" expression="${projectName}" />
</xslt>
</target>
<target name="execProjectAutomator">
<path id="pathProjectdefinition">
<pathelement location="${deployerProjectDefinition}" />
</path>
<pathconvert refid="pathProjectdefinition" property="pathProjectdefinitionFile"/>
<exec dir="${deployerInstallationPath}" executable="${deployerInstallationPath}/${deployerAutomatorExecutable}" failonerror="true" resultproperty="appState">
<arg value="${pathProjectdefinitionFile}" />
</exec>
<if>
<equals arg1="${appState}" arg2="0" trim="true"/>
<then>
<echo message ="Project Automator successfully executed."/>
</then>
<else>
<fail message="Project Automator failed."/>
</else>
</if>
</target>
<target name="triggerDeploy">
<exec executable="${deployerInstallationPath}/${deployerExecutable}" dir="${deployerInstallationPath}" failonerror="true" resultproperty="appState">
<arg value="--deploy"/>
<arg line="-project ${projectName}"/>
<arg line="-dc myDeployment"/>
<arg line="-host ${deployerHost}"/>
<arg line="-port ${deployerPort}"/>
<arg line="-user ${deployerUsername}"/>
<arg line="-pwd ${deployerPassword}"/>
<arg value="-force"/>
</exec>
<if>
<equals arg1="${appState}" arg2="0" trim="true"/>
<then>
<echo message="WMDeployer successfully executed."/>
</then>
<else>
<fail message="WMDeployer failed."/>
</else>
</if>
</target>
</project>