Maven deploy Release Note as artifact

0 votes

Requirement: Upload (deploy) an additional file (a text format release note file) along with jar/war to nexus.

Possible Solution: Use maven deploy plugin as below:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
                <execution>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <packaging>RELEASENOTE.MD</packaging>
                        <generatePom>false</generatePom>
                        <url>${project.distributionManagement.repository.url}</url>
                        <artifactId>${project.artifactId}</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <version>${project.version}</version>
                        <file>RELEASENOTE.MD</file>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Problems:

  1. RELEASENOTE.MD file is optional. The file should be deployed only if it is present. The above solution throws an error if the file is not present.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...\RELEASENOTE.MD not found.

  1. Need an option to specify file name by regex (example: *RELEASENOTE.MD). maven deploy plugin does not accept regex.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...*RELEASENOTE.MD not found.

How can these two problems be circumvented?

Jun 22, 2018 in DevOps Tools by Damon Salvatore
• 5,980 points
744 views

1 answer to this question.

0 votes

The following solution will do the trick:

<profiles>
    <profile>
        <id>add-release-note</id>
        <activation>
            <file><exists>RELEASENOTE.MD</exists></file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>attach-artifacts</id>
                            <phase>package</phase>
                            <goals>
                                <goal>attach-artifact</goal>
                            </goals>
                            <configuration>
                                <artifacts>
                                    <artifact>
                                        <file>RELEASENOTE.MD</file>
                                        <type>MD</type>
                                        <classifier>RELEASENOTE</classifier>
                                    </artifact>
                                </artifacts>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
Below are the two changes I have made in the above code.
  • maven-deploy-plugin within profile activation works too. However, it poses a difficulty for release/snapshot build parameterization due to its <url> tag. build-helper-maven-plugin is a simpler solution

  • Filename regex can be handled through a wrapper shell build script

I hope the above explanation would be helpful for you.

answered Jun 22, 2018 by Atul
• 10,240 points

Related Questions In DevOps Tools

+4 votes
2 answers

Jenkins not showing Maven Release Plugin

Make your project type Maven Project. This ...READ MORE

answered Oct 11, 2018 in DevOps Tools by Hannah
• 18,520 points
5,106 views
0 votes
1 answer

running comands as non-root user while using docker-maven plugin

Docker needs root access therefore maven commands ...READ MORE

answered Apr 30, 2018 in DevOps Tools by ajs3033
• 7,300 points
3,018 views
0 votes
0 answers

How to create maven build on bamboo ? Unable to create build by using profile as in pom.xml

As given in the above question that ...READ MORE

Oct 28 in DevOps Tools by Anila
• 4,940 points
47 views
0 votes
1 answer

How to deploy kafka cluster on cloud?

You can run kafka in both ways ...READ MORE

answered Jun 14, 2018 in DevOps Tools by DareDev
• 6,890 points
697 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,061 views
+2 votes
1 answer
0 votes
1 answer

Maven deploy “Release Note” as artifact

Using both @SpaceTrucker and @khmarbaise, came up with the following ...READ MORE

answered Jun 19, 2018 in DevOps Tools by Atul
• 10,240 points
1,355 views
0 votes
1 answer

How to deploy Liberty packaged server automatic delivery

Here is a concept regarding your query. It ...READ MORE

answered Jul 11, 2018 in DevOps Tools by Atul
• 10,240 points
905 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP