Skip to content

Conversation

@v-gayatrij
Copy link
Contributor

@v-gayatrij v-gayatrij commented Nov 20, 2025

Context

Describe the context or motivation for this PR. Include links to any related Azure DevOps Work Items or GitHub issues.
📌 Associated WI: AB#2327840


Task Name

MavenV4


Description

Remove second maven run(during code coverage publishing step) to avoid running maven lifecycle phases twice.
The second adds verify phase when JaCoCo is selected as the code coverage -

mvnReport.arg("verify");

This is because JaCoCo plugin binds its check goal to the Maven verify phase, which ensures that all tests have run and their coverage data is available - #6458 (comment).

This PR combines below 2 maven runs adding verify phase to the first run:

run to execute maven goals:

return mvnRun.exec(util.getExecOptions());

maven run before publishing code coverage:

mvnReport.exec().then(function (code) {


Risk Assessment (Low / Medium / High)

Low. Changes covered under feature flag


Change Behind Feature Flag (Yes / No)

Yes


Tech Design / Approach

  • Design has been written and reviewed.
  • Any architectural decisions, trade-offs, and alternatives are captured.

Documentation Changes Required (Yes/No)

Indicate whether related documentation needs to be updated.

  • User guides, API specs, system diagrams, or runbooks are updated.

Unit Tests Added or Updated (Yes / No)

Indicate whether unit tests were added or modified to reflect these changes.


Additional Testing Performed

canary test pipeline runs:

FF enabled - Pipelines - Run 20251125.8
FF disabled - Pipelines - Run 20251125.7


Logging Added/Updated (Yes/No)

  • Appropriate log statements are added with meaningful messages.
  • Logging does not expose sensitive data.
  • Log levels are used correctly (e.g., info, warn, error).

Telemetry Added/Updated (Yes/No)

  • Custom telemetry (e.g., counters, timers, error tracking) is added as needed.
  • Events are tagged with proper metadata for filtering and analysis.
  • Telemetry is validated in staging or test environments.

Rollback Scenario and Process (Yes/No)

  • Rollback plan is documented.

Dependency Impact Assessed and Regression Tested (Yes/No)

  • All impacted internal modules, APIs, services, and third-party libraries are analyzed.
  • Results are reviewed and confirmed to not break existing functionality.

Checklist

  • Related issue linked (if applicable)
  • Task version was bumped — see versioning guide
  • Verified the task behaves as expected

@v-gayatrij
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@v-gayatrij
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

const verifyOrLaterPhases = ['verify', 'install', 'deploy'];
const hasVerifyOrLater = mavenGoals.some(goal => verifyOrLaterPhases.includes(goal.toLowerCase()));

if (!hasVerifyOrLater) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if the user input in goals property has verify or a later phase as this will eventually execute verify phase.
If not, append verify argument to mvn command.

As per https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#default-lifecycle, install and deploy phases come after verify phase.
Since maven executes all the phases in sequential order upto the specified phase, adding verify to maven run command will not be needed if a later phase is already given as input.

}
mvnRun.arg(mavenGoals);

if (tl.getPipelineFeature('RemoveDuplicateMavenRun') && isCodeCoverageOpted && ccTool.toLowerCase() === "jacoco") {
Copy link
Contributor Author

@v-gayatrij v-gayatrij Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running maven upto verify phase is needed only when jacoco is selected as code coverage - tool.

mvnReport.arg("verify");

If jacoco is not selected as code coverage tool, flow will be as earlier and adding verify will not be required.

@v-gayatrij
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

sendCodeCoverageEmptyMsg();
defer.reject(err);
});
if (tl.getPipelineFeature('RemoveDuplicateMavenRun')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove maven execution if FF is enabled. The flow for both jacoco and cobertura code coverage tools will remain same in this case.

@v-gayatrij v-gayatrij marked this pull request as ready for review November 25, 2025 09:12
@v-gayatrij v-gayatrij requested review from a team and tarunramsinghani as code owners November 25, 2025 09:12
assert(testRunner.ran('/home/bin/maven/bin/mvn -f pom.xml help:effective-pom'), 'it should have generated effective pom');
assert(testRunner.ran('/home/bin/maven/bin/mvn -f pom.xml clean package'), 'it should have run mvn -f pom.xml package');
if (tl.getPipelineFeature('RemoveDuplicateMavenRun')){
assert(testRunner.ran('/home/bin/maven/bin/mvn -f pom.xml clean verify'), 'it should have run mvn -f pom.xml verify');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goals property has package as input in the task setup. The code coverage tool selected is JaCoCo.


In this case, verify will be appended to maven command as it executes after package phase as per Maven's build lifecycle - https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#default-lifecycle.

Comment on lines +322 to +324
if (tl.getPipelineFeature('RemoveDuplicateMavenRun')){
assert(testRunner.ran('/home/bin/maven/bin/mvn -f pom.xml clean verify'), 'it should have run mvn -f pom.xml verify');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this tested ? what is the mechanism to enable flag for L0 as this does not run in pieline the tl.getPipelineFeature('RemoveDuplicateMavenRun') will always be false ?

I think we need 1 test with FF disabled and 1 with enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants