Skip to content

Commit 1210382

Browse files
committed
JENKINS-72386: replace --no-transfer-progress option
-ntp is not supported on versions of maven prior to 3.8. Maven does exits with "unrecognized option" when it encounters an option it doesn't know about. This solution uses replaces the unsupported option with a system property to reduce the transfer logger used for batch mode to WARN only. See [MRELEASE-1048](https://issues.apache.org/jira/browse/MRELEASE-1048)
1 parent bfdcef7 commit 1210382

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos/pipe
168168
[#feature-sensible-default-maven-settings]
169169
=== Sensible default Maven parameters
170170

171-
The Maven parameters that are useful on a build server, `--batch-mode` (`-B`) and `--no-transfer-progress` (`-ntp`) are enable by default, no need to add them in your mvn invocations.
171+
The Maven parameters that are useful on a build server, `--batch-mode` (`-B`) is enable by default and transfer output is suppressed, no need to add them in your mvn invocations.
172172

173-
if **<<feature-traceability>>** is enabled, `--no-transfer-progress` (`-ntp`) option is removed, and `--show-version` (`-V`) is added.
173+
if **<<feature-traceability>>** is enabled, `--show-version` (`-V`) is added and transfer output is enabled.
174174

175175
[#feature-maven-integration-global-settings]
176176
=== Maven Settings Support

pipeline-maven/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution2.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ private void setupMaven(@NonNull Collection<Credentials> credentials) throws IOE
364364
boolean isUnix = Boolean.TRUE.equals(getComputer().isUnix());
365365
StringBuilder mavenConfig = new StringBuilder();
366366
mavenConfig.append("--batch-mode ");
367-
ifTraceabilityDisabled(() -> mavenConfig.append("--no-transfer-progress "));
367+
ifTraceabilityDisabled(() -> {
368+
// In batch-mode transfer output is sent through Slf4jMavenTransferListener
369+
// Not using -ntp because it breaks maven <=3.6 which does not support the option
370+
// Maven 4.0 supports CI=true to quite transfer output
371+
mavenConfig.append("-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn ");
372+
});
368373
ifTraceabilityEnabled(() -> mavenConfig.append("--show-version "));
369374
if (StringUtils.isNotEmpty(settingsFilePath)) {
370375
// JENKINS-57324 escape '%' as '%%'. See

0 commit comments

Comments
 (0)