From b74775215bde843e07e231ad0150769de58e22ab Mon Sep 17 00:00:00 2001 From: "Eshita Duvvada (MINDTREE LIMITED)" Date: Mon, 23 Dec 2024 10:59:33 +0530 Subject: [PATCH] Adding Feature Flag to RoboCopy in WindowsMachineFileCopyV2 --- .../WindowsMachineFileCopyV2/RoboCopyJob.ps1 | 21 ++++++++++++++++--- Tasks/WindowsMachineFileCopyV2/task.json | 2 +- Tasks/WindowsMachineFileCopyV2/task.loc.json | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 b/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 index 9dce5e2c966e..ce264c954cea 100644 --- a/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 @@ -1,4 +1,9 @@ -$CopyJob = { +$featureFlags = @{ + ModifyNumberOfRetriesInRobocopy = [System.Convert]::ToBoolean($env:MODIFY_NUMBER_OF_RETRIES_IN_ROBOCOPY) +} +$ModifyRoboCopyRetries= $featureFlags.ModifyNumberOfRetriesInRobocopy + +$CopyJob = { param ( [string]$fqdn, [string]$sourcePath, @@ -101,7 +106,12 @@ param ( function Clean-Target { - $cleanupArgument = "/NOCOPY /E /PURGE" + if(-not $ModifyRoboCopyRetries){ + $cleanupArgument = "/NOCOPY /E /PURGE" + } + else{ + $cleanupArgument = "/NOCOPY /E /PURGE /R:3 " + } $guid = [GUID]::NewGuid() $tempDirectory = "$scriptRoot\temp$guid" New-Item -ItemType Directory -Force -Path $tempDirectory @@ -128,7 +138,12 @@ param ( [switch]$fileCopy ) { - $robocopyParameters = "/COPY:DAT " + if(-not $ModifyRoboCopyRetries){ + $robocopyParameters = "/COPY:DAT " + } + else{ + $robocopyParameters = "/COPY:DAT /R:3 " + } if(-not $fileCopy.IsPresent) { diff --git a/Tasks/WindowsMachineFileCopyV2/task.json b/Tasks/WindowsMachineFileCopyV2/task.json index 9aae659178c6..2f22da598991 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.json +++ b/Tasks/WindowsMachineFileCopyV2/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 242, + "Minor": 250, "Patch": 0 }, "releaseNotes": "What's new in Version 2.0:
  Proxy support is being added.
   Removed support of legacy DTL machines.", diff --git a/Tasks/WindowsMachineFileCopyV2/task.loc.json b/Tasks/WindowsMachineFileCopyV2/task.loc.json index fef860146520..af125dea14e1 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.loc.json +++ b/Tasks/WindowsMachineFileCopyV2/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 242, + "Minor": 250, "Patch": 0 }, "releaseNotes": "ms-resource:loc.releaseNotes",