jiraBeing a lazy developer, I was recently searching for a way to automatically generate release notes instead of manually compiling the list. Fortunately, the maven changes plugin comes to the rescue. It can not only generate the release notes from JIRA tasks, but also email it to a list of email addresses.

I’m writing this post to collect all scattered information from different sources into a single place and provide a working example as I couldn’t find one on the internet.

Sample pom.xml

...
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-changes-plugin</artifactId>
      <version>2.11</version>
      <executions>
        <execution>
          <id>include-announcement-file</id>
          <phase>generate-resources</phase>
          <goals>
            <goal>announcement-generate</goal>
          </goals>
          <configuration>
            <!-- This will generate CHANGES.txt file under META-INF folder within the built artifact: -->
            <announcementFile>CHANGES.txt</announcementFile>
            <announcementDirectory>${project.build.outputDirectory}/META-INF</announcementDirectory>
          </configuration>
        </execution>
      </executions>
      <configuration>
        <issueManagementSystems>
          <issueManagementSystem>JIRA</issueManagementSystem>
        </issueManagementSystems>
        <smtpHost>mail.yourhost.com</smtpHost>
        <smtpPort implementation="java.lang.Integer">25</smtpPort>
        <mailSender>
          <name>Release Notification</name>
          <email>build@example.com</email>
        </mailSender>
        <toAddresses>
          <toAddress implementation="java.lang.String">to@example.com</toAddress>
        </toAddresses>
        <useJql>true</useJql>
        <!-- Use current build version: -->
        <onlyCurrentVersion>true</onlyCurrentVersion>
        <!-- use this to define a specific version:
        <fixVersionIds>11412</fixVersionIds>
        -->
        <resolutionIds>Fixed,Done</resolutionIds>
        <statusIds>Closed,Resolved,QA</statusIds>
        <columnNames>Type,Key,Summary,Priority,Status,Resolution,Fix Version,Assignee</columnNames>
        <webUser>myuser</webUser>
        <webPassword>mypassword</webPassword>
      </configuration>
    </plugin>
  </plugins>
</build>
...
<issueManagement>
  <system>JIRA</system>
  <url>https://abc.jira.com/browse/XY</url>
</issueManagement>
...
<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-changes-plugin</artifactId>
      <version>2.11</version>
    </plugin>
  </plugins>
</reporting>
...

Generate release notes html file

Run this command:

mvn changes:jira-report

Here’s a sample JIRA report:
https://maven.apache.org/plugins/maven-changes-plugin/jira-report.html

Generate and send email

Run this command:

mvn changes:announcement-mail

This will also be executed when deploying artifact to a maven repository using:

mvn deploy
Wrong form ID
  • nitin

    Getting below error, please let me know how can i resolve it,

    mvn deploy
    [INFO] Scanning for projects…
    [ERROR] The build could not read 1 project -> [Help 1]
    [ERROR]
    [ERROR] The project (/reports/pom.xml) has 1 error
    [ERROR] Non-parseable POM /reports/pom.xml: only whitespace content allowed before start tag and not . (position: START_DOCUMENT seen …. @1:1) @ line 1, column 1 -> [Help 2]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
    [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

    [root@jx-dop-jnkns-1 reports]# mvn clean install
    [INFO] Scanning for projects…
    [ERROR] The build could not read 1 project -> [Help 1]
    [ERROR]
    [ERROR] The project (/opt/reports/pom.xml) has 1 error
    [ERROR] Non-parseable POM /opt/reports/pom.xml: only whitespace content allowed before start tag and not . (position: START_DOCUMENT seen …. @1:1) @ line 1, column 1 -> [Help 2]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
    [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

    • David Kiss

      Hi Nitin,

      It looks like your pom.xml is not a valid XML document. You could use an online XML validator to find the issue.

  • Chris Graham

    Hi. Ideally I’d love to have the create release, create version and generate announcement steps tied to the deploy phase, so when you run the release plugin all of the Jira integration steps occur automatically.
    Have you seen this?
    Or have suggestions as to which way to go?

    • David Kiss

      Sorry but I’m not sure how to do that.