Skip to content

Instantly share code, notes, and snippets.

View TedHusted's full-sized avatar

Ted Husted TedHusted

View GitHub Profile
@TedHusted
TedHusted / 1-build-setproperty.xml
Last active July 2, 2017 13:00
Omitting XML stanza from package.xml if empty
<property name="sf_setupWeblink_xml"><![CDATA[<setupWeblink>${sf_setupWeblink}</setupWeblink>]]></property>
<condition property="sf_setupWeblink_element" value="${sf_setupWeblink_xml}" else="">
<isset property="sf_setupWeblink"/>
</condition>
@TedHusted
TedHusted / .gitattributes
Created June 27, 2017 10:37
Avoid merge conflicts in Force.com metadata with the union strategy
*.profile merge=union
*.object merge=union
*.layout merge=union
src/package.xml merge=union
@TedHusted
TedHusted / 1-build-required-string.xml
Last active July 9, 2017 11:28
Simple Ant target for making a property required.
<target name="taskRequired" depends="initHome">
<fail message="Must specify task.">
<condition>
<or>
<not>
<isset property="task"/>
</not>
<equals arg1="${task}" arg2=""/>
</or>
</condition>
@TedHusted
TedHusted / build-task.xml
Created June 10, 2017 13:55
Simple approach to making an Ant build script backwardly compatible
<target name="RegularTask">
<property name="version" value="old"/>
<antcall target="RegularTask_${version}"/>
</target>
<target name="RegularTask_old">
<!-- Legacy behavior -->
</target>
<target name="RegularTask_new">
@TedHusted
TedHusted / ct.sh
Created June 10, 2017 13:48
Simple Bash script to connect quickly to various servers by name.
#!/bin/bash
case "$1" in
'foxtrot')
IP='54.54.54.1'
;;
'tango')
IP='54.54.54.2'
;;
'whiskey')
IP='54.54.54.2'
@TedHusted
TedHusted / 1-listMetadata.xml
Last active June 10, 2017 10:12
Generates a package.xml from ListMetadata text output.
<target name="list" depends="initHome">
<property name="sf_metadataType" value="CustomMetadata"/>
<property name="sf_folder" value="${sf_sourcedir}/${sf_metadataType}"/>
<echo level="info">Retrieving components from the org using ...
username="${sf_username}"
password="${sf_password}${sf_securityToken}"
serverurl="${sf_serverurl}"
metadataType="${sf_metadataType}"
folder="${sf_folder}"
resultFilePath="${homedir}/listMetadata.xml"</echo>
@TedHusted
TedHusted / postPullRequest.xml
Last active June 2, 2017 11:14
Invokes a bash script with environment parameters.
<target name="postPullRequest" depends="initRepo">
<echo level="info">Creating Pull Request using ...
"${tooldir}/sh/${post_pull_request_script}"
repo_full_name="${repo_full_name}"
repo_password="${repo_password}"
repo_user="${repo_user}"
</echo>
<exec executable="bash" failonerror="${sf_failOnError}">
<arg value="${tooldir}/sh/${post_pull_request_script}"/>
<env key="repo_full_name" value="${repo_full_name}"/>
@TedHusted
TedHusted / pull_request.sh
Created June 2, 2017 01:29
Creates pull request in GitHub repository using REST API.
#!/bin/bash
echo ${repo_post_pull_request_payload_github}
curl -X POST -H "Content-Type: application/json" --user ${repo_user}:${repo_password} https://api.github.com/repos/${repo_owner}/${repo_full_name}/pulls --data ${repo_post_pull_request_payload_github}
@TedHusted
TedHusted / 1-sf_package_xml.xml
Last active June 2, 2017 23:41
Sets XML file content to an Ant property, and then writes the file in another target.
<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>
@TedHusted
TedHusted / createFlowFolders.xml
Created June 2, 2017 01:20
Writes a package.xml file from an Ant echo task.
<target name="createFlowFolders" depends="initHome">
<mkdir dir="${homedir}/server"/>
<echo file="${homedir}/server/package.xml" append="false"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>Flow</name>
</types>
<types>
<members>*</members>