Skip to content

Commit af5a829

Browse files
authored
Merge pull request #11210 from tanu-shree136/users/tanu/telemetryM156
[M156] Adding telemetry in PublishTestResults task to get dotnet version
2 parents 7ca570b + bf8236b commit af5a829

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Tasks/PublishTestResultsV2/publishtestresults.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import * as publishTestResultsTool from './publishtestresultstool';
33
import * as tl from 'azure-pipelines-task-lib/task';
4+
import * as tr from 'azure-pipelines-task-lib/toolrunner';
45
import * as ci from './cieventlogger';
56

67
const MERGE_THRESHOLD = 100;
@@ -43,6 +44,20 @@ function publish(testRunner, resultFiles, mergeResults, failTaskOnFailedTests, p
4344
tl.command('results.publish', properties, '');
4445
}
4546

47+
function getDotNetVersion() {
48+
let dotnet: tr.ToolRunner;
49+
const dotnetPath = tl.which('dotnet', false);
50+
51+
if (dotnetPath){
52+
try {
53+
dotnet = tl.tool(dotnetPath);
54+
dotnet.arg('--version');
55+
return dotnet.execSync().stdout.trim();
56+
} catch (err) {}
57+
}
58+
return '';
59+
}
60+
4661
async function run() {
4762
try {
4863
tl.setResourcePath(path.join(__dirname, 'task.json'));
@@ -76,7 +91,7 @@ async function run() {
7691
allowBrokenSymbolicLinks: true,
7792
followSpecifiedSymbolicLink: true,
7893
followSymbolicLinks: true
79-
};
94+
};
8095

8196
const matchingTestResultsFiles = tl.findMatch(searchFolder, testResultsFiles, findOptions);
8297

@@ -91,6 +106,9 @@ async function run() {
91106
ci.addToConsolidatedCi('platform', platform);
92107
ci.addToConsolidatedCi('testResultsFilesCount', testResultsFilesCount);
93108

109+
const dotnetVersion = getDotNetVersion();
110+
ci.addToConsolidatedCi('dotnetVersion', dotnetVersion);
111+
94112
const forceMerge = testResultsFilesCount > MERGE_THRESHOLD;
95113
if (forceMerge) {
96114
tl.debug('Detected large number of test result files. Merged all of them into a single file and published a single test run to optimize for test result publish performance instead of publishing hundreds of test runs');

Tasks/PublishTestResultsV2/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 2,
1616
"Minor": 156,
17-
"Patch": 0
17+
"Patch": 1
1818
},
1919
"demands": [],
2020
"releaseNotes": "<ul><li>NUnit3 support</li><li>Support for Minimatch files pattern</li></ul>",

Tasks/PublishTestResultsV2/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 2,
1616
"Minor": 156,
17-
"Patch": 0
17+
"Patch": 1
1818
},
1919
"demands": [],
2020
"releaseNotes": "ms-resource:loc.releaseNotes",

0 commit comments

Comments
 (0)