Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 KB | None | 0 0
  1. <project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
  2.  
  3. <property file="build.properties"/>
  4. <property environment="env"/>
  5.  
  6. <!-- Setting default value for username, password and session id properties to empty string
  7. so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
  8. will be treated literally.
  9. -->
  10. <condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
  11. <condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
  12. <condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>
  13.  
  14. <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
  15. <classpath>
  16. <pathelement location="../ant-salesforce.jar" />
  17. </classpath>
  18. </taskdef>
  19.  
  20. <!-- Test out deploy and retrieve verbs for package 'mypkg' -->
  21. <target name="test">
  22. <!-- Upload the contents of the "mypkg" package -->
  23. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="mypkg" rollbackOnError="true"/>
  24. <mkdir dir="retrieveOutput"/>
  25. <!-- Retrieve the contents into another directory -->
  26. <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveOutput" packageNames="MyPkg"/>
  27. </target>
  28.  
  29. <!-- Retrieve an unpackaged set of metadata from your org -->
  30. <!-- The file unpackaged/package.xml lists what is to be retrieved -->
  31. <target name="retrieveUnpackaged">
  32. <mkdir dir="retrieveUnpackaged"/>
  33. <!-- Retrieve the contents into another directory -->
  34. <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveUnpackaged" unpackaged="src/package.xml"/>
  35. </target>
  36.  
  37. <!-- Retrieve all the items of a particular metadata type -->
  38. <target name="bulkRetrieve">
  39. <sf:bulkRetrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" metadataType="${sf.metadataType}" retrieveTarget="retrieveUnpackaged"/>
  40. </target>
  41.  
  42. <!-- Retrieve metadata for all the packages specified under packageNames -->
  43. <target name="retrievePkg">
  44. <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveOutput" packageNames="${sf.pkgName}"/>
  45. </target>
  46.  
  47. <!-- Deploy the unpackaged set of metadata retrieved with retrieveUnpackaged and run tests in this organization's namespace only-->
  48. <target name="deployUnpackaged">
  49. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="retrieveUnpackaged" rollbackOnError="true"/>
  50. </target>
  51.  
  52. <!-- Deploy a zip of metadata files to the org -->
  53. <target name="deployZip">
  54. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" zipFile="${sf.zipFile}" pollWaitMillis="10000" rollbackOnError="true"/>
  55. </target>
  56.  
  57. <!-- Shows deploying code & running tests for code in directory -->
  58. <target name="deployCode">
  59. <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
  60. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" testLevel="NoTestRun" rollbackOnError="true" ignoreWarnings="true">
  61. </sf:deploy>
  62. </target>
  63.  
  64. <target name="deployCodeRunAllTests">
  65. <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
  66. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" testLevel="RunAllTestsInOrg" rollbackOnError="true" ignoreWarnings="true">
  67. </sf:deploy>
  68. </target>
  69.  
  70. <target name="deployCodeRunAllTestsProd">
  71. <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
  72. <sf:deploy username="${sf.username.prod}" password="${sf.password.prod}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl.prod}" maxPoll="${sf.maxPoll}" deployRoot="src" testLevel="RunAllTestsInOrg" rollbackOnError="true" ignoreWarnings="true">
  73. </sf:deploy>
  74. </target>
  75.  
  76. <!-- Shows deploying code with no TestLevel sepcified -->
  77. <target name="deployCodeNoTestLevelSpecified">
  78. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" rollbackOnError="true"/>
  79. </target>
  80.  
  81. <!-- Shows deploying code and running tests only within the org namespace -->
  82. <target name="deployCodeRunLocalTests">
  83. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" rollbackOnError="true" testlevel="RunLocalTests"/>
  84. </target>
  85.  
  86. <!-- Shows removing code; only succeeds if done after deployCode -->
  87. <target name="undeployCode">
  88. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="removesrc"/>
  89. </target>
  90.  
  91. <!-- Shows retrieving code; only succeeds if done after deployCode -->
  92. <target name="retrieveCode">
  93. <!-- Retrieve the contents listed in the file codepkg/package.xml into the codepkg directory -->
  94. <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="src" unpackaged="src/package.xml"/>
  95. </target>
  96.  
  97. <!-- Shows retrieving code; only succeeds if done after deployCode -->
  98. <target name="retrieveCodeProd">
  99. <!-- Retrieve the contents listed in the file codepkg/package.xml into the codepkg directory -->
  100. <sf:retrieve username="${sf.username.prod}" password="${sf.password.prod}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl.prod}" maxPoll="${sf.maxPoll}" retrieveTarget="src" unpackaged="src/package.xml"/>
  101. </target>
  102.  
  103. <!-- Shows deploying code, running all tests, and running tests (1 of which fails), and logging. -->
  104. <target name="deployCodeFailingTest">
  105. <!-- Upload the contents of the "codepkg" package, running all tests -->
  106. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" testLevel="RunAllTestsInOrg" rollbackOnError="true" logType="Debugonly"/>
  107. </target>
  108.  
  109. <!-- Shows check only; never actually saves to the server -->
  110. <target name="deployCodeCheckOnly">
  111. <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="src" testLevel="RunAllTestsInOrg" checkOnly="true"/>
  112. </target>
  113.  
  114. <!-- Shows quick deployment of recent validation. Set the property sf.recentValidationId to your recent check only deployment Id -->
  115. <target name="quickDeploy">
  116. <sf:deployRecentValidation username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" recentValidationId="${sf.recentValidationId}"/>
  117. </target>
  118.  
  119. <!-- Shows cancel deployment of deploy request either pending or in progress. Set property sf.requestId to Id of pending or in progress deploy request -->
  120. <target name="cancelDeploy">
  121. <sf:cancelDeploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" requestId="${sf.requestId}"/>
  122. </target>
  123.  
  124. <!-- Retrieve the information of all items of a particular metadata type -->
  125. <target name="listMetadata">
  126. <sf:listMetadata username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" metadataType="${sf.metadataType}"/>
  127. </target>
  128.  
  129. <!-- Retrieve the information on all supported metadata type -->
  130. <target name="describeMetadata">
  131. <sf:describeMetadata username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}"/>
  132. </target>
  133.  
  134. <target name="intcheck">
  135. <sf:deploy
  136. username="${sf.int.username}"
  137. password="${sf.int.password}"
  138. serverurl="${sf.serverurl_sandbox_dev}"
  139. deployRoot="src"
  140. ignoreWarnings="true"
  141. pollWaitMillis="10000"
  142. maxPoll="300"
  143. checkOnly="true"
  144. testLevel="NoTestRun"/>
  145. </target>
  146. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement