You could use Azure PowerShell task to run your script to find the new or modified files committed to the repo and then copy them to your blob storage container.
The following is the code snippet.
#get a list of all files that are part of the commit given SHA
$result=$(git diff-tree --no-commit-id --name-status -r $(Build.SourceVersion))
#The result looks like "M test/hello.txt A today.txt"
$array=$Result.Split(" ")
#The arraylooks like "
#M test/hello.txt
#A today.txt"
foreach ($ele in $array)
{
#Added (A), Copied (C), Deleted (D), Modified (M)
if ($ele.Contains("M") -eq 0 -Or $ele.Contains("A") -eq 0)
{
#filename looks like "test/hello.txt"
$fileName=$ele.Substring(2)
$sourcePath="$(Build.SourcesDirectory)" + "\" + $fileName
#your azcopy code here
}
}
Another easier workaround is that you could use the PowerShell task to find the new or modified files committed to the repo and then copy them to a new $(Build.SourcesDirectory)/temp
folder with corresponding path structure, and then still use the Azure File Copy task to copy files under the $(Build.SourcesDirectory)/temp
folder to your blob storage container.
# Write your PowerShell commands here.
Write-Host "Hello World"
$result=$(git diff-tree --no-commit-id --name-status -r $(Build.SourceVersion))
$array=$Result.Split(" ")
md $(Build.SourcesDirectory)/temp
foreach ($ele in $array)
{
if ($ele.Contains("M") -eq 0 -Or $ele.Contains("A") -eq 0)
{
$fileName=$ele.Substring(2)
$source="$(Build.SourcesDirectory)" + "\" + $fileName
$destination="$(Build.SourcesDirectory)/temp" + "\" + $fileName
New-Item $destination -type file -Force
Copy-Item -Path $source -Destination $destination
}
}
#Get-ChildItem -Path $(Build.SourcesDirectory)/temp –Recurse