-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-init.xml
219 lines (173 loc) · 8.91 KB
/
build-init.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<project name="sfInit" >
<!-- SETUP TARGETS: Intializes shared properties via the initHome AND initRepo targets. -->
<!--
There are two targets that initialize properties, initRepo and initHome.
Separating the repository properties simplifies testing, and also helps
with understanding the context for each of the many properties.
-->
<target name="initCheckOnly"
description="Sets properties for a CheckOnly deploy. Must be called before initHome (or any target the depends on initHome).">
<property name="sf_checkOnly" value="true"/>
<property name="sf_testLevel" value="RunLocalTests"/>
</target>
<target name="initNoTestRun" description="Sets testLevel. Must be called before initHome (or any target the depends on initHome).">
<property name="sf_testLevel" value="NoTestRun"/>
</target>
<target name="initRepo" depends="initRepoCore,initRepoHost"/>
<target name="initRepoCore">
<!-- Fallback to properties file for any repo fields not aleady set. -->
<property file="${homedir}/build_repo.properties"/>
<property file="${tooldir}/build_repo.properties"/>
<!--
To use a task branch, set the task or sandbox property from the command
line:
-Dtask=ABC-1234
-Dsandbox=staging
Otherwise, the production org and master branch are used
-->
<!--
When a task is set, and the sandbox is not set, the sandbox name becomes
the task ID, without the separating hyphen (ABC-123 to ABC123).
-->
<script language="javascript">
if (project.getProperty('task') !== undefined && project.getProperty('task') != null) {
arr = project.getProperty('task').split('-');
if (arr.length==1) {
project.setProperty('sandbox', arr[0]);
} else {
project.setProperty('sandbox', arr[0].concat(arr[1]));
project.setProperty('number', arr[1]);
}
}
</script>
<!-- Set branch to the task value if task is defined. -->
<condition property="branch" value="${task}">
<isset property="task"/>
</condition>
<!-- Set branch to the sandbox value if sandbox is defined. -->
<condition property="branch" value="${sandbox}">
<isset property="sandbox"/>
</condition>
<!-- Fallback for any repo fields not set. -->
<property name="branch" value="master"/>
<property name="task" value=""/>
<property name="parentdir" value="${basedir}"/>
<property name="commitmask" value="/src/*"/>
<property name="commitdir" value="${homedir}${commitmask}"/>
<property name="remote" value="origin"/>
<property name="destination" value="develop"/>
<property name="close_source_branch" value="false"/>
<!-- Set your own repo details in the properties file. -->
<property file="${tooldir}/build_repo.properties"/>
<property name="repo_config_user" value="${repo_user}"/>
<property name="repo_config_email_domain" value="example.com"/>
<property name="repo_config_email" value="${repo_config_user}@${repo_config_email_domain}"/>
<property name="repo_description" value=""/>
<property name="repo_message" value="Committed by build agent"/>
<!-- Set home and repo_host to generate the other "repo_" properties. -->
<property name="repo_name" value="${home}"/>
<property name="repo_full_name" value="${repo_owner}/${repo_name}"/>
<property name="repo_host" value="bitbucket.org"/>
<property name="repo_path" value="${repo_host}/${repo_full_name}"/>
<property name="repo_url" value="https://${repo_user}:${repo_password}@${repo_path}"/>
<!-- Setup pull request for Bitbucket. -->
<property name="repo_post_pull_request_payload_bitbucket">{ "title": "${task}
${repo_message}", "description": "${repo_description}", "source": { "branch": { "name": "${branch}" }, "repository": { "full_name": "${repo_full_name}" } }, "destination": { "branch": { "name": "${destination}" } }, "reviewers": [ { "username": "" } ], "close_source_branch": ${close_source_branch} }</property>
<!-- Setup pull request for GitHub. -->
<property name="repo_post_pull_request_payload_github">{ "title": "${task} ${repo_message}", "body": "${repo_description}", "head": "${branch}", "base": "${destination}" }</property>
</target>
<target name="initRepoHost" depends="initBitbucket,initGitHub"/>
<target name="initBitbucket" depends="isRepoHostBitbucket" if="is_repo_host_bitbucket" >
<echo>Setting pull request payload script to Bitbucket version ...</echo>
<property name="post_pull_request_script" value="post_pull_request_bitbucket"/>
<echo>post_pull_request_script is ${post_pull_request_script}</echo>
</target>
<target name="isRepoHostBitbucket">
<condition property="is_repo_host_bitbucket">
<equals arg1="${repo_host}" arg2="bitbucket.org" />
</condition>
</target>
<target name="initGitHub" depends="isRepoHostGitHub" if="is_repo_host_github" >
<echo>Setting pull request payload script to GitHub version ...</echo>
<property name="post_pull_request_script" value="post_pull_request_github"/>
<echo>post_pull_request_script is ${post_pull_request_script}</echo>
</target>
<target name="isRepoHostGitHub">
<condition property="is_repo_host_github">
<equals arg1="${repo_host}" arg2="github.com" />
</condition>
</target>
<!--
The initHome target initializes the properties needed to manage
Salesforce Orgs and associated sandboxes.
A default build_sf.properties is bundled with the build.xml, which can
be overridden from the CLI or build server.
-->
<target name="initHome" depends="initRepo">
<!-- Fallback to properties file for any sf fields not aleady set. -->
<property file="${tooldir}/build_local.properties"/>
<property file="${tooldir}/build_sf.properties"/>
<!--
If sf_credentials is set, parse into sf_username_org, and sf_password.
Expected credential format: "[email protected]:passwordsecurityToken"
-->
<script language="javascript">
if (project.getProperty('sf_credentials') !== undefined && project.getProperty('sf_credentials') != null) {
arr = project.getProperty('sf_credentials').split(':');
if (arr.length==2) {
project.setProperty('sf_username_org', arr[0]);
project.setProperty('sf_password_org', arr[1]);
}
}
</script>
<!-- Alternative to specifying a sandbox property. -->
<condition property="sf_serverurl" value="https://${sf_host}.salesforce.com">
<isset property="sf_host"/>
</condition>
<!-- Adjust properties if sandbox is set, or fallback. -->
<property name="sf_serverurl_test" value="https://test.salesforce.com"/>
<condition property="sf_serverurl" value="${sf_serverurl_test}">
<isset property="sandbox"/>
</condition>
<property name="sf_serverurl" value="https://login.salesforce.com"/>
<condition property="sf_username" value="${sf_username_org}.${sandbox}">
<isset property="sandbox"/>
</condition>
<property name="sf_username" value="${sf_username_org}"/>
<property name="sf_password" value="${sf_password_org}"/>
<!-- Set token to empty if not already set, so we can append it for authentication. -->
<property name="sf_securityToken" value=""/>
<!-- Default to single-package deployment. -->
<property name="sf_packageNames" value="${sf_fullName}"/>
<property name="sf_xmlns"
value="http://soap.sforce.com/2006/04/metadata"/>
<!-- Minimal package.xml manifests that deploy Salesforce components from
a local folder. -->
<condition property="sf_postInstallClass" value="">
<not>
<isset property="sf_postInstallClass"/>
</not>
</condition>
<condition property="sf_setupWeblink" value="">
<not>
<isset property="sf_setupWeblink"/>
</not>
</condition>
<property name="sf_package_xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><Package xmlns="${sf_xmlns}">
<fullName>${sf_fullName}</fullName>
<postInstallClass>${sf_postInstallClass}</postInstallClass>
<setupWeblink>${sf_setupWeblink}</setupWeblink>
<version>${sf_apiVersion}</version>
</Package>]]></property>
<property name="sf_unpackaged_xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><Package xmlns="${sf_xmlns}">
<version>${sf_apiVersion}</version>
</Package>]]></property>
<property name="sf_InstalledPackage_xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><Package xmlns="${sf_xmlns}">
<types>
<members>*</members>
<name>InstalledPackage</name>
</types>
<version>${sf_apiVersion}</version>
</Package>]]></property>
</target>
</project>