This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dist-tool.git
The following commit(s) were added to refs/heads/master by this push:
new f3ba4cf Skip the Jenkins reports when API_TOKEN is not set
f3ba4cf is described below
commit f3ba4cfd06937aa553bc92f59eb0904adc7ff04d
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Nov 9 16:22:32 2026 +0100
Skip the Jenkins reports when API_TOKEN is not set
ci-maven.apache.org rejects anonymous JSON API requests, so without a token
list-master-jobs and list-branches made one failing request per repository
and published an empty table. They now render a page saying the token is
missing instead.
---
README.md | 2 +-
.../maven/dist/tools/jobs/AbstractJobsReport.java | 34 ++++++++++++++++++++++
.../tools/jobs/branches/ListBranchesReport.java | 3 ++
.../tools/jobs/master/ListMasterJobsReport.java | 3 ++
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6cd0a9f..6422656 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ The `API_TOKEN` environment variable is needed by the two
Jenkins reports (`list
It is a Base64-encoded `username:apitoken` string used for HTTP Basic
Authentication.
Everything else (gitbox, maven.apache.org, dist/archive.apache.org,
lists.apache.org) is read
-anonymously. Without the token the two reports still build, but come out empty.
+anonymously. Without the token the two reports skip Jenkins and render a page
saying the token is missing.
#### Generating the Token
diff --git
a/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
index eb7e0c6..c230686 100644
--- a/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
+++ b/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
@@ -25,7 +25,9 @@ import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.dist.tools.JsoupRetry;
+import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
@@ -55,6 +57,38 @@ public abstract class AbstractJobsReport extends
AbstractMavenReport {
"maven-studies",
"maven-xinclude-extension");
+ /**
+ * The Jenkins JSON API of ci-maven.apache.org does not allow anonymous
access, so without an
+ * {@code API_TOKEN} every request fails and the report would come out
empty. In that case render
+ * a page saying so instead, without calling Gitbox or Jenkins.
+ *
+ * @param title the report title
+ * @return {@code true} if the report was skipped and the caller must
return
+ */
+ protected boolean skipWithoutApiToken(String title) {
+ if (StringUtils.isNotBlank(System.getenv("API_TOKEN"))) {
+ return false;
+ }
+ getLog().warn("API_TOKEN is not set: skipping " + title + ", Jenkins
does not allow anonymous API access");
+
+ Sink sink = getSink();
+ sink.head();
+ sink.title();
+ sink.text(title);
+ sink.title_();
+ sink.head_();
+ sink.body();
+ sink.paragraph();
+ sink.text("This report was not generated: it reads the ");
+ sink.link(MAVENBOX_JOBS_BASE_URL + "..");
+ sink.text("Jenkins jobs");
+ sink.link_();
+ sink.text(" through the Jenkins JSON API, which needs the API_TOKEN
environment variable.");
+ sink.paragraph_();
+ sink.body_();
+ return true;
+ }
+
/**
* Extract Git repository names for Apache Maven from
* <a href="https://gitbox.apache.org/repos/asf">Gitbox main page</a>,
diff --git
a/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
index d192bfd..f21105c 100644
---
a/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
+++
b/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
@@ -185,6 +185,9 @@ public class ListBranchesReport extends AbstractJobsReport {
/** {@inheritDoc} */
@Override
protected void executeReport(Locale locale) throws MavenReportException {
+ if (skipWithoutApiToken("List Branches")) {
+ return;
+ }
Collection<String> repositoryNames = repositoryNames();
List<Result> repoStatus = Flux.fromIterable(repositoryNames)
diff --git
a/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
index ab414e6..c5da820 100644
---
a/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
+++
b/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
@@ -76,6 +76,9 @@ public class ListMasterJobsReport extends AbstractJobsReport {
/** {@inheritDoc} */
@Override
protected void executeReport(Locale locale) throws MavenReportException {
+ if (skipWithoutApiToken("List Master Jobs")) {
+ return;
+ }
Collection<String> repositoryNames = repositoryNames();
List<Result> repoStatus = Flux.fromIterable(repositoryNames)