Skip to content

Commit

Permalink
Resolves #280 - bot files fail to deploy after version is activated.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfloess committed Nov 8, 2022
1 parent f37cfcd commit 5f45214
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
22 changes: 22 additions & 0 deletions ant/1.1/util/rh-util.xml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@
</sequential>
</macrodef>

<!-- =========================================================================================== -->

<macrodef name="processFilesAsList" backtrace="true" uri="http://www.redhat.com/util" description="Iterate over @{list} and process each value">
<attribute name="param"/>
<attribute name="dir"/>
<attribute name="listDelimiter" default=" "/>

<element name="Process" implicit="yes" description="Will be called for each element in @{list}"/>

<sequential>
<path id="processFilesAsList.files.id">
<fileset dir="@{dir}"/>
</path>

<pathconvert targetos="unix" property="processFilesAsList.files" refid="processFilesAsList.files.id"/>

<rh-util:processList param="@{param}" list="${processFilesAsList.files}" listDelimiter="@{listDelimiter}">
<Process/>
</rh-util:processList>
</sequential>
</macrodef>

<!-- =========================================================================================== -->

<macrodef name="applyPropertyFiles" backtrace="true" uri="http://www.redhat.com/util" description="Apply property files">
Expand Down
53 changes: 50 additions & 3 deletions ant/1.1/util/sfdc-util.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,7 @@ ${sfdc-util.SF-JAR.PATH}
<attribute name="replaceVarsFile" default="${sf.replaceVarsFile}" description="A file containing any variables that should be replaced before deployment"/>
<attribute name="ignoreWarnings" default="${sf.ignoreWarnings}" description="Flag, if true, denotes that a deployment should succeed even if there are warnings when deploying"/>
<attribute name="ignoreFile" default="${sf.ignoreFile}" description="A file containing patterns/file names of what to exclude when deploying"/>
<attribute name="excludes" default="" description="List of files to exclude when deploying: useful to compute files for exclusion unrelated to the ignoreFile"/>
<attribute name="checkOnly" default="${sf.checkOnly}" description="Flag, if true, denotes check the validity of the deployed files without making any changes in the organization"/>
<attribute name="logType" default="${sf.logType}" description="Debugging level for running tests. Can be None, Debugonly, Db, Profling, Callout or Detail"/>
<attribute name="dryRun" default="${sf.dryRun}" description="If set to anything other than an empty string, will assume you do not want to deploy"/>
Expand Down Expand Up @@ -3119,7 +3120,7 @@ ${sfdc-util.SF-JAR.PATH}
-->
<rh-util:ifNotEqual arg1="${file-push.IGNORE_FILE_CONTENTS}" arg2="">
<rh-util:then>
<zip destfile="${file-push.DEPLOY_FILE}" basedir="${file-push.tmp.DIR}" excludesfile="@{ignoreFile}" level="9"/>
<zip destfile="${file-push.DEPLOY_FILE}" basedir="${file-push.tmp.DIR}" excludesfile="@{ignoreFile}" excludes="@{excludes}" level="9"/>

<pathconvert property="file-push.PATH">
<fileset dir="${file-push.tmp.DIR}" includesFile="@{ignoreFile}"/>
Expand All @@ -3138,7 +3139,7 @@ ${sfdc-util.SF-JAR.PATH}
</rh-util:then>

<rh-util:else>
<zip destfile="${file-push.DEPLOY_FILE}" basedir="${file-push.tmp.DIR}" level="9"/>
<zip destfile="${file-push.DEPLOY_FILE}" basedir="${file-push.tmp.DIR}" excludes="@{excludes}" level="9"/>
</rh-util:else>
</rh-util:ifNotEqual>

Expand All @@ -3153,6 +3154,7 @@ ${sfdc-util.SF-JAR.PATH}
Destructive changes file: [@{destructiveChangesFile}]

Ignoring: [${file-push.PATH}]
Excludes: [@{excludes}]

URL: [${file-push.URL}]
API: [${file-push.VERSION}]
Expand Down Expand Up @@ -3500,6 +3502,49 @@ ${sfdc-util.SF-JAR.PATH}
]]>
</scriptdef>

<macrodef name="compute-bot-excludes" backtrace="true" uri="http://www.redhat.com/sfdc" description="This pushes a list of files from @{masterEnv} to @{dependentEnv} based on added/modified files">
<attribute name="masterEnv" default="${solenopsis.env.MASTER}" description="The master environment who has the correct data defined"/>
<attribute name="dependentEnv" default="${solenopsis.env.DEPENDENT}" description="The dependent environment from which to push"/>
<attribute name="property" description="The property to set when computing files to ignore"/>

<sequential>
<rh-util:processFilesAsList param="compute-bot-excludes.excludes" dir="${solenopsis.env.@{masterEnv}.HOME}/bots">
<rh-util:baseName property="compute-bot-excludes.BOT_FILE_BASENAME" file="@{compute-bot-excludes.excludes}"/>

<rh-util:ifFileExists file="${solenopsis.env.@{dependentEnv}.HOME}/bots/${compute-bot-excludes.BOT_FILE_BASENAME}">
<rh-util:then>
<xmlproperty file="@{compute-bot-excludes.excludes}" collapseAttributes="true" prefix="compute-bot-excludes_master"/>
<xmlproperty file="${solenopsis.env.@{dependentEnv}.HOME}/bots/${compute-bot-excludes.BOT_FILE_BASENAME}" collapseAttributes="true" prefix="compute-bot-excludes_deps"/>

<rh-util:ifEqual arg1="${compute-bot-excludes_master.Bot.botVersions.fullName}" arg2="${compute-bot-excludes_deps.Bot.botVersions.fullName}">
<rh-util:then>
<rh-util:appendProperty name="@{property}" value=" **/${compute-bot-excludes.BOT_FILE_BASENAME}"/>

<rh-util:propertyDereference name="toEcho" property="@{property}"/>
</rh-util:then>
</rh-util:ifEqual>
</rh-util:then>

<rh-util:else>
<echo message="NO"/>
</rh-util:else>
</rh-util:ifFileExists>
</rh-util:processFilesAsList>
</sequential>
</macrodef>

<macrodef name="compute-excludes" backtrace="true" uri="http://www.redhat.com/sfdc" description="This pushes a list of files from @{masterEnv} to @{dependentEnv} based on added/modified files">
<attribute name="masterEnv" default="${solenopsis.env.MASTER}" description="The master environment who has the correct data defined"/>
<attribute name="dependentEnv" default="${solenopsis.env.DEPENDENT}" description="The dependent environment from which to push"/>
<attribute name="property" description="The property to set when computing files to ignore"/>

<sequential>
<rh-sfdc:compute-bot-excludes masterEnv="@{masterEnv}" dependentEnv="@{dependentEnv}" property="compute-excludes.BOTS"/>

<ac:var name="@{property}" value="${compute-excludes.BOTS}"/>
</sequential>
</macrodef>

<macrodef name="delta-push" backtrace="true" uri="http://www.redhat.com/sfdc" description="This pushes a list of files from @{masterEnv} to @{dependentEnv} based on added/modified files">
<attribute name="masterEnv" default="${solenopsis.env.MASTER}" description="The master environment who has the correct data defined"/>
<attribute name="dependentEnv" default="${solenopsis.env.DEPENDENT}" description="The dependent environment from which to push"/>
Expand Down Expand Up @@ -3530,11 +3575,13 @@ ${sfdc-util.SF-JAR.PATH}

<rh-util:dirDiff src="${solenopsis.env.@{masterEnv}.HOME}" dest="${solenopsis.env.@{dependentEnv}.HOME}" addProperty="delta-push.ADD" modProperty="delta-push.MOD" delProperty="delta-push.DEL" delimiter="@{fileDelimiter}"/>

<rh-sfdc:compute-excludes property="delta-push.EXCLUDES"/>

<rh-sfdc:ensureMetadataPairs data="${delta-push.MOD}" property="delta-push.MOD" delimiter="@{fileDelimiter}"/>

<rh-sfdc:computeFieldDiffs dir="${solenopsis.env.@{dependentEnv}.HOME}" compareDir="${solenopsis.env.@{masterEnv}.HOME}" property="delta-push.REMOVE_FIELDS"/>

<rh-sfdc:file-push masterEnv="@{masterEnv}" dependentEnv="@{dependentEnv}" addFileList="${delta-push.ADD}@{fileDelimiter}${delta-push.MOD}" removeFileList="${delta-push.DEL}" removeFieldList="${delta-push.REMOVE_FIELDS}" fileDelimiter="@{fileDelimiter}" trace="@{trace}" runAllTests="@{runAllTests}" testLevel="@{testLevel}" maxPoll="@{maxPoll}" allowMissingFiles="@{allowMissingFiles}" replaceVarsFile="@{replaceVarsFile}" ignoreWarnings="@{ignoreWarnings}" ignoreFile="@{ignoreFile}" checkOnly="@{checkOnly}" logType="@{logType}" dryRun="@{dryRun}" fastDeploy="@{fastDeploy}" xslDir="@{xslDir}"/>
<rh-sfdc:file-push masterEnv="@{masterEnv}" dependentEnv="@{dependentEnv}" addFileList="${delta-push.ADD}@{fileDelimiter}${delta-push.MOD}" removeFileList="${delta-push.DEL}" removeFieldList="${delta-push.REMOVE_FIELDS}" fileDelimiter="@{fileDelimiter}" trace="@{trace}" runAllTests="@{runAllTests}" testLevel="@{testLevel}" maxPoll="@{maxPoll}" allowMissingFiles="@{allowMissingFiles}" replaceVarsFile="@{replaceVarsFile}" ignoreWarnings="@{ignoreWarnings}" ignoreFile="@{ignoreFile}" excludes="${delta-push.EXCLUDES}" checkOnly="@{checkOnly}" logType="@{logType}" dryRun="@{dryRun}" fastDeploy="@{fastDeploy}" xslDir="@{xslDir}"/>
</sequential>
</macrodef>

Expand Down

0 comments on commit 5f45214

Please sign in to comment.