Skip to content

Commit a98621f

Browse files
authored
[VMR] Use CopyFiles@2 task instead of manual copying (#45479)
1 parent b5e0903 commit a98621f

File tree

2 files changed

+30
-64
lines changed

2 files changed

+30
-64
lines changed

eng/pipelines/templates/jobs/vmr-build.yml

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -496,70 +496,30 @@ jobs:
496496
displayName: Run Tests
497497
timeoutInMinutes: ${{ variables.runTestsTimeout }}
498498
499-
- ${{ if eq(parameters.targetOS, 'windows') }}:
500-
501-
# Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph.
502-
- powershell: |
503-
function CopyWithRelativeFolders($sourcePath, $targetFolder, $filter) {
504-
Get-ChildItem -Path $sourcePath -Filter $filter -Recurse | ForEach-Object {
505-
$targetPath = Join-Path $targetFolder (Resolve-Path -Relative $_.FullName)
506-
New-Item -ItemType Directory -Path (Split-Path -Parent $targetPath) -Force | Out-Null
507-
Copy-Item $_.FullName -Destination $targetPath -Force
508-
Write-Host "Copied $_ to $targetPath"
509-
}
510-
}
511-
512-
$targetFolder = "$(Build.ArtifactStagingDirectory)/BuildLogs/"
513-
New-Item -ItemType Directory -Path $targetFolder -Force | Out-Null
514-
515-
cd "$(sourcesPath)"
516-
517-
CopyWithRelativeFolders "artifacts/log/" $targetFolder "*"
518-
519-
if (Test-Path "artifacts/scenario-tests/") {
520-
CopyWithRelativeFolders "artifacts/scenario-tests/" $targetFolder "*.binlog"
521-
echo "##vso[task.setvariable variable=hasScenarioTestResults]true"
522-
}
523-
524-
if (Test-Path "artifacts/TestResults/*") {
525-
CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.binlog"
526-
CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.diff"
527-
CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "Updated*.txt"
528-
CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.trx"
529-
}
530-
displayName: Prepare BuildLogs staging directory and check assets
531-
continueOnError: true
532-
condition: succeededOrFailed()
533-
534-
- ${{ else }}:
535-
536-
# Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph.
537-
- script: |
538-
set -ex
539-
540-
targetFolder=$(Build.ArtifactStagingDirectory)/BuildLogs/
541-
mkdir -p ${targetFolder}
542-
543-
cd "$(sourcesPath)"
544-
545-
find artifacts/log/ -exec cp --parents {} ${targetFolder} \;
546-
547-
if [ -d "artifacts/scenario-tests/" ]; then
548-
find artifacts/scenario-tests/ -type f -name "*.binlog" -exec cp --parents {} ${targetFolder} \;
549-
echo "##vso[task.setvariable variable=hasScenarioTestResults]true"
550-
fi
551-
552-
if [ -d "artifacts/TestResults/" ]; then
553-
find artifacts/TestResults/ -type f -name "*.binlog" -exec cp --parents {} ${targetFolder} \;
554-
find artifacts/TestResults/ -type f -name "*.diff" -exec cp --parents {} ${targetFolder} \;
555-
find artifacts/TestResults/ -type f -name "Updated*.txt" -exec cp --parents {} ${targetFolder} \;
556-
find artifacts/TestResults/ -type f -name "*.trx" -exec cp --parents {} ${targetFolder} \;
557-
fi
558-
559-
if [[ "${{ parameters.buildSourceOnly }}" == "True" ]]; then
560-
find artifacts/prebuilt-report/ -exec cp --parents {} ${targetFolder} \;
561-
fi
562-
displayName: Prepare BuildLogs staging directory and check assets
499+
- task: CopyFiles@2
500+
displayName: Prepare BuildLogs staging directory
501+
inputs:
502+
SourceFolder: '$(sourcesPath)'
503+
Contents: |
504+
artifacts/log/**
505+
artifacts/scenario-tests/**/*.binlog
506+
artifacts/TestResults/**/*.binlog
507+
artifacts/TestResults/**/*.diff
508+
artifacts/TestResults/**/Updated*.txt
509+
artifacts/TestResults/**/*.trx
510+
artifacts/TestResults/**/*.xml
511+
TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs'
512+
CleanTargetFolder: true
513+
continueOnError: true
514+
condition: succeededOrFailed()
515+
516+
- ${{ if eq(parameters.buildSourceOnly, 'True') }}:
517+
- task: CopyFiles@2
518+
displayName: Copy prebuilt-report to BuildLogs
519+
inputs:
520+
SourceFolder: '$(sourcesPath)'
521+
Contents: artifacts/prebuilt-report/**
522+
TargetFolder: '$(Build.ArtifactStagingDirectory)/BuildLogs'
563523
continueOnError: true
564524
condition: succeededOrFailed()
565525

src/SourceBuild/content/repo-projects/scenario-tests.proj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@
5757
</ItemGroup>
5858
</Target>
5959

60+
<Target Name="SetAzureDevOpsVariableForScenarioTests"
61+
Condition="'$(ContinuousIntegrationBuild)' == 'true'"
62+
BeforeTargets="Test">
63+
<Message Importance="High" Text="##vso[task.setvariable variable=hasScenarioTestResults]true" />
64+
</Target>
65+
6066
</Project>

0 commit comments

Comments
 (0)