Skip to content

Commit c914723

Browse files
authored
Fix trailing slashes in report directory (#9536)
1 parent 69533ad commit c914723

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Tasks/PublishCodeCoverageResultsV1/publishcodecoverageresults.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function run() {
1919
// Resolve the summary file path.
2020
// It may contain wildcards allowing the path to change between builds, such as for:
2121
// $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage\cobertura.xml
22-
var resolvedSummaryFile: string = resolvePathToSingleItem(workingDirectory, summaryFileLocation);
22+
var resolvedSummaryFile: string = resolvePathToSingleItem(workingDirectory, summaryFileLocation, false);
2323
if (failIfCoverageIsEmpty && await ccUtil.isCodeCoverageFileEmpty(resolvedSummaryFile, codeCoverageTool)) {
2424
throw tl.loc('NoCodeCoverage');
2525
} else if (!tl.exist(resolvedSummaryFile)) {
@@ -28,7 +28,7 @@ async function run() {
2828
// Resolve the report directory.
2929
// It may contain wildcards allowing the path to change between builds, such as for:
3030
// $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage
31-
var resolvedReportDirectory: string = resolvePathToSingleItem(workingDirectory, reportDirectory);
31+
var resolvedReportDirectory: string = resolvePathToSingleItem(workingDirectory, reportDirectory, true);
3232

3333
// Get any 'Additional Files' to publish as build artifacts
3434
if (additionalFiles) {
@@ -54,12 +54,16 @@ async function run() {
5454
}
5555

5656
// Resolves the specified path to a single item based on whether it contains wildcards
57-
function resolvePathToSingleItem(workingDirectory:string, pathInput: string) : string {
57+
function resolvePathToSingleItem(workingDirectory:string, pathInput: string, isDirectory: boolean) : string {
5858
// Default to using the specific pathInput value
5959
var resolvedPath: string = pathInput;
6060

61-
// Does the pathInput value contain wildcards?
6261
if (pathInput) {
62+
63+
// Find match patterns won't work if the directory has a trailing slash
64+
if (isDirectory && (pathInput.endsWith('/') || pathInput.endsWith('\\'))) {
65+
pathInput = pathInput.slice(0, -1);
66+
}
6367
// Resolve matches of the pathInput pattern
6468
var pathMatches: string[] = tl.findMatch(
6569
workingDirectory,

Tasks/PublishCodeCoverageResultsV1/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 1,
19-
"Minor": 145,
19+
"Minor": 148,
2020
"Patch": 0
2121
},
2222
"demands": [],

Tasks/PublishCodeCoverageResultsV1/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"author": "Microsoft Corporation",
1616
"version": {
1717
"Major": 1,
18-
"Minor": 139,
18+
"Minor": 148,
1919
"Patch": 0
2020
},
2121
"demands": [],

0 commit comments

Comments
 (0)