Skip to content

Commit e2dc979

Browse files
authored
Adding option to provide pom/gradle path for Azure Test Plan task (#20630)
* [draft] adding option for user to provide custom pom/gradle file paths. * version bump. * gradle file location. * visibleRule. * version. * - not working with visible rule. * updated task. * task.loc josn updated. * update help markdown. * _generated files.
1 parent faa494f commit e2dc979

File tree

19 files changed

+198
-46
lines changed

19 files changed

+198
-46
lines changed

Tasks/AzureTestPlanV0/Invokers/gradleinvoker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import utils = require('../utils');
33
import constants = require('../constants');
44
import { execGradleBuild } from '../testLibExecutor';
55

6-
export async function executeGradleTests(testsToBeExecuted: string[]):Promise<number> {
6+
export async function executeGradleTests(testsToBeExecuted: string[], gradleFilePath?: string): Promise<number> {
77

88
//public doc link: https://docs.gradle.org/current/userguide/command_line_interface.html
99
//gradle command like "gradlew clean test --tests <package.className.testName> --tests <package.className.testName>"
1010

1111
const executable = constants.GRADLE_EXECUTABLE;
1212
let args: string[] = [];
1313

14+
if (gradleFilePath) {
15+
args.push('-b', gradleFilePath);
16+
}
17+
1418
args.push('test');
1519

1620
for (let testcase of testsToBeExecuted) {

Tasks/AzureTestPlanV0/Invokers/maveninvoker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils = require('../utils');
44
import constants = require('../constants');
55
import { execMavenBuild } from '../testLibExecutor';
66

7-
export async function executeMavenTests(testsToBeExecuted: string[]):Promise<number> {
7+
export async function executeMavenTests(testsToBeExecuted: string[], pomFilePath?: string):Promise<number> {
88

99
//public doc link: https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
1010
//maven command like "mvn test -Dtest=<package.className#testName>,<package.className#testName1>"
@@ -28,6 +28,11 @@ export async function executeMavenTests(testsToBeExecuted: string[]):Promise<num
2828
args.push(combinedTestArgs);
2929
}
3030

31+
if (pomFilePath) {
32+
args.push('-f');
33+
args.push(pomFilePath);
34+
}
35+
3136
tl.debug("Executing java maven tests with executable : " + executable);
3237
tl.debug("Executing java maven tests with args :" + args);
3338

Tasks/AzureTestPlanV0/automatedTestInvoker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { executeJestTests } from './Invokers/jestinvoker';
99
export async function testInvoker(testsToBeExecuted: string[], ciData: ciDictionary): Promise<number> {
1010

1111
const testLanguage = tl.getInput('testLanguageInput', true);
12+
const pomFilePath = tl.getInput('pomFilePath');
13+
const gradleFilePath = tl.getInput('gradleFilePath');
1214

1315
let exitStatusCode = 0;
1416
let exitCode = 0;
@@ -19,14 +21,14 @@ export async function testInvoker(testsToBeExecuted: string[], ciData: ciDiction
1921
}
2022

2123
switch (testLanguage) {
22-
case 'Java-Maven':
23-
exitCode = await executeMavenTests(testsToBeExecuted);
24+
case 'JavaMaven':
25+
exitCode = await executeMavenTests(testsToBeExecuted, pomFilePath);
2426
tl.debug(`Execution Status Code for Maven: ${exitCode}`);
2527
ciData["isJavaMavenExecution"] = true;
2628
break;
2729

28-
case 'Java-Gradle':
29-
exitCode = await executeGradleTests(testsToBeExecuted);
30+
case 'JavaGradle':
31+
exitCode = await executeGradleTests(testsToBeExecuted, gradleFilePath);
3032
tl.debug(`Execution Status Code for Gradle: ${exitCode}`);
3133
ciData["isJavaGradleExecution"] = true;
3234
break;

Tasks/AzureTestPlanV0/task.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 248,
1717
"Patch": 0
1818
},
1919
"preview": true,
@@ -77,13 +77,31 @@
7777
"label": "Select Test framework language",
7878
"helpMarkDown": "Test Framework Language of automated tests in test plan",
7979
"options": {
80-
"Java-Maven": "Java-Maven",
81-
"Java-Gradle": "Java-Gradle",
80+
"JavaMaven": "Java-Maven",
81+
"JavaGradle": "Java-Gradle",
8282
"Python": "Python",
8383
"Go": "Go",
8484
"Jest": "Jest"
8585
}
8686
},
87+
{
88+
"name": "pomFilePath",
89+
"type": "string",
90+
"label": "Pom file path",
91+
"defaultValue": "",
92+
"required": false,
93+
"helpMarkDown": "Relative path from the repository root to the Maven POM file.",
94+
"visibleRule": "testLanguageInput = JavaMaven"
95+
},
96+
{
97+
"name": "gradleFilePath",
98+
"type": "string",
99+
"label": "Gradle file path",
100+
"defaultValue": "",
101+
"required": false,
102+
"helpMarkDown": "Relative path from the repository root to the build.gradle file.",
103+
"visibleRule": "testLanguageInput = JavaGradle"
104+
},
87105
{
88106
"name": "mergeTestResults",
89107
"type": "boolean",

Tasks/AzureTestPlanV0/task.loc.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 248,
1717
"Patch": 0
1818
},
1919
"preview": true,
@@ -77,13 +77,31 @@
7777
"label": "ms-resource:loc.input.label.testLanguageInput",
7878
"helpMarkDown": "ms-resource:loc.input.help.testLanguageInput",
7979
"options": {
80-
"Java-Maven": "Java-Maven",
81-
"Java-Gradle": "Java-Gradle",
80+
"JavaMaven": "Java-Maven",
81+
"JavaGradle": "Java-Gradle",
8282
"Python": "Python",
8383
"Go": "Go",
8484
"Jest": "Jest"
8585
}
8686
},
87+
{
88+
"name": "pomFilePath",
89+
"type": "string",
90+
"label": "ms-resource:loc.input.label.pomFilePath",
91+
"defaultValue": "",
92+
"required": false,
93+
"helpMarkDown": "ms-resource:loc.input.help.pomFilePath",
94+
"visibleRule": "testLanguageInput = JavaMaven"
95+
},
96+
{
97+
"name": "gradleFilePath",
98+
"type": "string",
99+
"label": "ms-resource:loc.input.label.gradleFilePath",
100+
"defaultValue": "",
101+
"required": false,
102+
"helpMarkDown": "ms-resource:loc.input.help.gradleFilePath",
103+
"visibleRule": "testLanguageInput = JavaGradle"
104+
},
87105
{
88106
"name": "mergeTestResults",
89107
"type": "boolean",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.246.0
2-
Node20-225|0.246.1
1+
Default|0.248.0
2+
Node20-225|0.248.1

_generated/AzureTestPlanV0/.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
registry=https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/
2+
3+
always-auth=true

_generated/AzureTestPlanV0/Invokers/gradleinvoker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import utils = require('../utils');
33
import constants = require('../constants');
44
import { execGradleBuild } from '../testLibExecutor';
55

6-
export async function executeGradleTests(testsToBeExecuted: string[]):Promise<number> {
6+
export async function executeGradleTests(testsToBeExecuted: string[], gradleFilePath?: string): Promise<number> {
77

88
//public doc link: https://docs.gradle.org/current/userguide/command_line_interface.html
99
//gradle command like "gradlew clean test --tests <package.className.testName> --tests <package.className.testName>"
1010

1111
const executable = constants.GRADLE_EXECUTABLE;
1212
let args: string[] = [];
1313

14+
if (gradleFilePath) {
15+
args.push('-b', gradleFilePath);
16+
}
17+
1418
args.push('test');
1519

1620
for (let testcase of testsToBeExecuted) {

_generated/AzureTestPlanV0/Invokers/maveninvoker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils = require('../utils');
44
import constants = require('../constants');
55
import { execMavenBuild } from '../testLibExecutor';
66

7-
export async function executeMavenTests(testsToBeExecuted: string[]):Promise<number> {
7+
export async function executeMavenTests(testsToBeExecuted: string[], pomFilePath?: string):Promise<number> {
88

99
//public doc link: https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
1010
//maven command like "mvn test -Dtest=<package.className#testName>,<package.className#testName1>"
@@ -28,6 +28,11 @@ export async function executeMavenTests(testsToBeExecuted: string[]):Promise<num
2828
args.push(combinedTestArgs);
2929
}
3030

31+
if (pomFilePath) {
32+
args.push('-f');
33+
args.push(pomFilePath);
34+
}
35+
3136
tl.debug("Executing java maven tests with executable : " + executable);
3237
tl.debug("Executing java maven tests with args :" + args);
3338

_generated/AzureTestPlanV0/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"loc.input.help.testConfiguration": "Select Test Configuration.",
1414
"loc.input.label.testLanguageInput": "Select Test framework language",
1515
"loc.input.help.testLanguageInput": "Test Framework Language of automated tests in test plan",
16+
"loc.input.label.pomFilePath": "Pom file path",
17+
"loc.input.help.pomFilePath": "Relative path from the repository root to the Maven POM file.",
18+
"loc.input.label.gradleFilePath": "Gradle file path",
19+
"loc.input.help.gradleFilePath": "Relative path from the repository root to the build.gradle file.",
1620
"loc.input.label.mergeTestResults": "Merge test results",
1721
"loc.input.help.mergeTestResults": "A test run is created for each results file. Check this option to merge results into a single test run. To optimize for better performance, results will be merged into a single run if there are more than 100 result files, irrespective of this option.",
1822
"loc.input.label.publishRunAttachments": "Upload test results files",

0 commit comments

Comments
 (0)