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-changes-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 6e756a4 [MCHANGES-389] Populate Release.description from JIRA
fixVersion
6e756a4 is described below
commit 6e756a490af341ee3b9be50848dc68f971dcd6f7
Author: Arturo Bernal <[email protected]>
AuthorDate: Wed Nov 11 19:00:20 2026 +0100
[MCHANGES-389] Populate Release.description from JIRA fixVersion
RestJiraDownloader parsed a fixVersion's name but dropped its
description field, so Issue never recorded it and IssueAdapter had
nothing to put in Release.description. Velocity templates referencing
${release.description} always rendered it empty for JIRA-sourced
changes, even though the JIRA REST API returns the description
alongside the version name.
Issue now keeps a fixVersion -> description map and exposes it via
getFixVersionDescription(), RestJiraDownloader reads the description
node when present, and IssueAdapter fills Release.description from it
the first time a release is created.
Added an announcement-generate IT that stubs a JIRA fixVersion with a
description and asserts it reaches the rendered template.
Fixes #259
---
.../invoker.properties | 17 +++
.../pom.xml | 59 +++++++++++
.../setup.groovy | 114 +++++++++++++++++++++
.../template-directory/test-announce.vm | 17 +++
.../verify.groovy | 31 ++++++
.../apache/maven/plugins/changes/IssueAdapter.java | 3 +
.../apache/maven/plugins/changes/issues/Issue.java | 28 +++++
.../plugins/changes/jira/RestJiraDownloader.java | 4 +-
.../maven/plugins/changes/IssueAdapterTest.java | 13 +++
9 files changed, 285 insertions(+), 1 deletion(-)
diff --git
a/src/it/announcement-generate-jira-release-description/invoker.properties
b/src/it/announcement-generate-jira-release-description/invoker.properties
new file mode 100644
index 0000000..3e70cf3
--- /dev/null
+++ b/src/it/announcement-generate-jira-release-description/invoker.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+invoker.goals = changes:announcement-generate
diff --git a/src/it/announcement-generate-jira-release-description/pom.xml
b/src/it/announcement-generate-jira-release-description/pom.xml
new file mode 100644
index 0000000..3946943
--- /dev/null
+++ b/src/it/announcement-generate-jira-release-description/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin-test</artifactId>
+ <version>2.1</version>
+ <name>Maven</name>
+ <packaging>jar</packaging>
+ <description>Test that release.description is populated from a JIRA
fixVersion's own description</description>
+
+ <properties>
+ <changesPluginVersion>@project.version@</changesPluginVersion>
+ </properties>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>${mockServerUrl}/browse/TEST_PROJECT</url>
+ </issueManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <version>${changesPluginVersion}</version>
+ <configuration>
+ <issueManagementSystems>
+ <issueManagementSystem>JIRA</issueManagementSystem>
+ </issueManagementSystems>
+ <jiraServerId>jira</jiraServerId>
+ <template>test-announce.vm</template>
+ <templateDirectory>template-directory</templateDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/it/announcement-generate-jira-release-description/setup.groovy
b/src/it/announcement-generate-jira-release-description/setup.groovy
new file mode 100644
index 0000000..37496a4
--- /dev/null
+++ b/src/it/announcement-generate-jira-release-description/setup.groovy
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.github.tomakehurst.wiremock.WireMockServer
+import com.github.tomakehurst.wiremock.common.ConsoleNotifier
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
+import static com.github.tomakehurst.wiremock.client.WireMock.configureFor
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo
+import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson
+import static com.github.tomakehurst.wiremock.client.WireMock.get
+import static com.github.tomakehurst.wiremock.client.WireMock.post
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
+
+WireMockServer wireMockServer = new
WireMockServer(WireMockConfiguration.options()
+ .dynamicPort()
+ .notifier(new ConsoleNotifier(false)))
+wireMockServer.start()
+
+def userProperties = context.get('userProperties')
+userProperties.put('mockServerUrl', wireMockServer.baseUrl())
+
+configureFor(wireMockServer.port())
+
+stubFor(get('/rest/api/2/serverInfo')
+ .withHeader('accept', equalTo('application/json'))
+ .willReturn(aResponse().withStatus(200)))
+
+stubFor(post('/rest/auth/1/session')
+ .withHeader('accept', equalTo('application/json'))
+ .withHeader('content-type', equalTo('application/json'))
+ .withRequestBody(equalToJson('{"username" : "jira-test", "password" :
"jira-password"}'))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader('Set-Cookie',
'JSESSIONID=D6961281D4A029FFA4E6BC8A526CF5CC; Path=/; HttpOnly')))
+
+stubFor(get('/rest/api/2/status')
+ .withHeader('accept', equalTo('application/json'))
+ .withCookie('JSESSIONID', equalTo('D6961281D4A029FFA4E6BC8A526CF5CC'))
+ .willReturn(aResponse().withStatus(200)
+ .withBody('[{"name": "Closed","id": "6"}]')))
+
+stubFor(get('/rest/api/2/resolution')
+ .withHeader('accept', equalTo('application/json'))
+ .withCookie('JSESSIONID', equalTo('D6961281D4A029FFA4E6BC8A526CF5CC'))
+ .willReturn(aResponse().withStatus(200)
+ .withBody('[{"name": "Fixed","id": "1"}]')))
+
+stubFor(post('/rest/api/2/search')
+ .withHeader('accept', equalTo('application/json'))
+ .withHeader('content-type', equalTo('application/json'))
+ .withCookie('JSESSIONID', equalTo('D6961281D4A029FFA4E6BC8A526CF5CC'))
+ .willReturn(aResponse().withStatus(200)
+ .withBody('''
+{
+ "issues": [
+ {
+ "id": "13036790",
+ "key": "TEST_PROJECT-1",
+ "fields": {
+ "assignee": {
+ "name": "assigned-user",
+ "displayName": "Assigned User"
+ },
+ "created": "2024-11-21T12:10:35.000+0000",
+ "updated": "2024-11-22T20:05:52.000+0000",
+ "components": [
+ { "name": "jira" }
+ ],
+ "fixVersions": [
+ { "name": "2.1", "description": "First stable release" },
+ { "name": "3.1", "description": "Second release" }
+ ],
+ "issuetype": {
+ "name": "Bug"
+ },
+ "priority": {
+ "name": null
+ },
+ "reporter": null,
+ "resolution": {
+ "name": "Fixed"
+ },
+ "status": {
+ "name": "Closed"
+ },
+ "summary": "Authentication does not work after Upgrade",
+ "versions": [
+ { "name": "2.12.1" }
+ ]
+ }
+ }]
+}
+''')))
+
+context.put("wireMockServer", wireMockServer)
+true
diff --git
a/src/it/announcement-generate-jira-release-description/template-directory/test-announce.vm
b/src/it/announcement-generate-jira-release-description/template-directory/test-announce.vm
new file mode 100644
index 0000000..ddb50cf
--- /dev/null
+++
b/src/it/announcement-generate-jira-release-description/template-directory/test-announce.vm
@@ -0,0 +1,17 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+Release description: ${release.description}
diff --git
a/src/it/announcement-generate-jira-release-description/verify.groovy
b/src/it/announcement-generate-jira-release-description/verify.groovy
new file mode 100644
index 0000000..27e0706
--- /dev/null
+++ b/src/it/announcement-generate-jira-release-description/verify.groovy
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.github.tomakehurst.wiremock.WireMockServer
+
+WireMockServer wireMockServer = context.get("wireMockServer")
+wireMockServer.stop()
+
+File report = new File(basedir, "target/announcement/test-announce.vm")
+assert report.isFile()
+
+String content = report.text
+
+// MCHANGES-389: a JIRA fixVersion's own description must reach
${release.description}, not be silently dropped.
+assert content.contains("Release description: First stable release")
diff --git a/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
b/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
index b7a015e..fe2af48 100644
--- a/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
+++ b/src/main/java/org/apache/maven/plugins/changes/IssueAdapter.java
@@ -78,6 +78,9 @@ public class IssueAdapter {
release.setVersion(fixVersion);
releasesMap.put(fixVersion, release);
}
+ if (release.getDescription() == null) {
+
release.setDescription(issue.getFixVersionDescription(fixVersion));
+ }
// Add this issue as an Action to this release
Action action = createAction(issue);
diff --git a/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
b/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
index 24b87ef..5f2e6d1 100644
--- a/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
+++ b/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
@@ -20,7 +20,9 @@ package org.apache.maven.plugins.changes.issues;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* An issue.
@@ -38,6 +40,8 @@ public class Issue {
private List<String> fixVersions;
+ private Map<String, String> fixVersionDescriptions;
+
private String id;
private String key;
@@ -94,10 +98,34 @@ public class Issue {
}
public void addFixVersion(String fixVersion) {
+ addFixVersion(fixVersion, null);
+ }
+
+ /**
+ * @param fixVersion the name of the fix version
+ * @param description the issue tracker's own description of that version,
e.g. JIRA's per-version
+ * description, or {@code null} if none is available
+ */
+ public void addFixVersion(String fixVersion, String description) {
if (fixVersions == null) {
fixVersions = new ArrayList<>();
}
fixVersions.add(fixVersion);
+
+ if (description != null) {
+ if (fixVersionDescriptions == null) {
+ fixVersionDescriptions = new HashMap<>();
+ }
+ fixVersionDescriptions.put(fixVersion, description);
+ }
+ }
+
+ /**
+ * @param fixVersion the name of the fix version
+ * @return the issue tracker's own description of that version, or {@code
null} if none was recorded
+ */
+ public String getFixVersionDescription(String fixVersion) {
+ return fixVersionDescriptions == null ? null :
fixVersionDescriptions.get(fixVersion);
}
public String getId() {
diff --git
a/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
b/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
index ef5e562..715b3ad 100644
---
a/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
+++
b/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
@@ -667,7 +667,9 @@ public class RestJiraDownloader {
for (int vx = 0; vx < val.size(); vx++) {
JsonNode fvNode = val.get(vx);
if (isNotNullNode(fvNode) &&
isNotNullNode(fvNode.get("name"))) {
- issue.addFixVersion(fvNode.get("name").asText());
+ JsonNode descriptionNode = fvNode.get("description");
+ String description = isNotNullNode(descriptionNode) ?
descriptionNode.asText() : null;
+ issue.addFixVersion(fvNode.get("name").asText(),
description);
}
}
}
diff --git
a/src/test/java/org/apache/maven/plugins/changes/IssueAdapterTest.java
b/src/test/java/org/apache/maven/plugins/changes/IssueAdapterTest.java
index 0398956..2282641 100644
--- a/src/test/java/org/apache/maven/plugins/changes/IssueAdapterTest.java
+++ b/src/test/java/org/apache/maven/plugins/changes/IssueAdapterTest.java
@@ -168,4 +168,17 @@ public class IssueAdapterTest {
assertEquals("1.0.0-alpha", releases.get(3).getVersion());
assertEquals("0.1.1", releases.get(4).getVersion());
}
+
+ @Test
+ public void testReleaseDescriptionFromFixVersion() {
+ IssueAdapter adapter = new IssueAdapter(new
JIRAIssueManagementSystem());
+
+ Issue issue = createIssue("TST-1", "Bug");
+ issue.addFixVersion("1.0", "First stable release");
+
+ List<Release> releases = adapter.getReleases(Arrays.asList(issue));
+
+ assertEquals(1, releases.size());
+ assertEquals("First stable release", releases.get(0).getDescription());
+ }
}