DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How to Publish Artifacts to Maven Central
  • Mulesoft 4: Continuous Delivery/Deployment With Maven
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]
  • Solid Testing Strategies for Salesforce Releases

Trending

  • Analyzing “java.lang.OutOfMemoryError: Failed to create a thread” Error
  • Enhancing Security With ZTNA in Hybrid and Multi-Cloud Deployments
  • Understanding and Mitigating IP Spoofing Attacks
  • Medallion Architecture: Efficient Batch and Stream Processing Data Pipelines With Azure Databricks and Delta Lake
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Running the Maven Release Plugin with Jenkins

Running the Maven Release Plugin with Jenkins

Learn more about using the Maven Release plugin on Jenkins, including subversion source control, artifactory, continuous integration, and more.

By 
$$anonymous$$ user avatar
$$anonymous$$
·
May. 23, 14 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
104.4K Views

Join the DZone community and get the full member experience.

Join For Free

jenkins
recently i started to implement our release process in jenkins . until then i just ran the release plugin of maven on my local machine which did the job. as i said we decided to move this task to jenkins. the build/release toolstack was:

  • subversion as source control
  • artifactory as internal maven repository
  • jenkins for continious integration
  • java source code as maven projects

to show my jenkins configuration i have setup a very basic maven module named ‘myapp’ with the following pom:


<?xml version="1.0" encoding="utf-8"?>
<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>net.pascalalma.demo</groupid>
    <artifactid>myapp</artifactid>
    <packaging>pom</packaging>
    <version>1.0.1-snapshot</version>
    <name>${project.artifactid}</name>
    <properties>
        <jdk.version>1.7</jdk.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>${project.build.sourceencoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-release-plugin</artifactid>
                <version>2.4.2</version>
            </plugin>
        </plugins>
    </build>
    <scm>
        <developerconnection>scm:svn:https://svn.4synergy.nl/sandbox/myapp/trunk</developerconnection>
    </scm>

    <distributionmanagement>
        <repository>
            <id>ec2-arti</id>
            <url>http://artifactory.4synergy.nl/artifactory/libs-release-local</url>
        </repository>
        <snapshotrepository>
            <id>ec2-arti</id>
            <url>http://artifactory.4synergy.nl/artifactory/libs-snapshot-local</url>
        </snapshotrepository>
    </distributionmanagement>
</project>


as you can see not much special here: i have included the release plugin of maven, the scm developers connection so it can check-in and out the code of the svn repository and artifactory as repositories to deploy to.

and of course not to forget the following maven settings file:

<?xml version="1.0" encoding="utf-8"?>
<settings xmlns="http://maven.apache.org/settings/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
          xsi:schemalocation="http://maven.apache.org/settings/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <username>admin</username>
      <password>password</password>
      <id>ec2-arti</id>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <mirrorof>*</mirrorof>
      <name>remote-repos</name>
      <url>http://artifactory.4synergy.nl/artifactory/remote-repos</url>
      <id>remote-repos</id>
    </mirror>
  </mirrors>
</settings>

with this setup i can run the maven release plugin locally like this:
mvn -b release:clean release:prepare release:perform

this will do all the stuff the maven release plugin should do and results in svn with the following structure:
screen shot 2014-05-06 at 14.55.44

and in artifactory it will show the following:
screen shot 2014-05-06 at 14.58.48
so that works. now let me show you what steps i needed to make it work on a separated jenkins server.

with the following config in jenkins i can check-out and build my maven module:
screen shot 2014-05-06 at 16.47.34

the next step is to run the release plugin of maven. for this i use the following jenkins plugin that i added to the jenkins configuration:
screen shot 2014-05-06 at 16.56.36

after installing this plugin you can configure the maven release plugin in your module configuration. it will generate some extra options in the module configuration:
screen shot 2014-05-07 at 21.00.45

now with this plugin in place i get an extra menu option to start your release build:
screen shot 2014-05-07 at 21.03.17

after i made sure the os user that is running jenkins could execute svn on the jenkins server and had access to the svn repository i ran into the following issue:

[info] [info] uploading: http://54.216.254.98/artifactory/libs-release-local/net/pascalalma/demo/myapp/1.0.3/myapp-1.0.3.pom
[info] [info] ------------------------------------------------------------------------
[info] [info] build failure
[info] [info] ------------------------------------------------------------------------
[info] [info] total time: 40.501 s
[info] [info] finished at: 2014-05-07t18:45:13+00:00
[info] [info] final memory: 12m/30m
[info] [info] ------------------------------------------------------------------------
[info] [error] failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project myapp: failed to deploy artifacts: could not transfer artifact net.pascalalma.demo:myapp:pom:1.0.3 from/to ec2-arti (http://54.216.254.98/artifactory/libs-release-local): failed to transfer file: http://54.216.254.98/artifactory/libs-release-local/net/pascalalma/demo/myapp/1.0.3/myapp-1.0.3.pom. return code is: 401, reasonphrase: unauthorized. -> [help 1]
[info] [error]
[info] [error] to see the full stack trace of the errors, re-run maven with the -e switch.
[info] [error] re-run maven using the -x switch to enable full debug logging.
[info] [error]
[info] [error] for more information about the errors and possible solutions, please read the following articles:
[info] [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojoexecutionexception
[info] ------------------------------------------------------------------------
[info] build failure
[info] ------------------------------------------------------------------------
[info] total time: 02:05 min
[info] finished at: 2014-05-07t18:45:14+00:00
[info] final memory: 9m/21m
[info] ------------------------------------------------------------------------
[error] failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:perform (default-cli) on project myapp: maven execution failed, exit code: '1' -> [help 1]
[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/mojoexecutionexception
[jenkins] archiving /opt/bitnami/apps/jenkins/jenkins_home/jobs/my-app/workspace/pom.xml to net.pascalalma.demo/myapp/1.0.3-snapshot/myapp-1.0.3-snapshot.pom
channel stopped
finished: failure

in my local environment i have defined the necessary username and pasword for the artifactory instance in my maven settings.xml but it is missing this info when running the maven job in jenkins. now we can add this settings.xml also to the user running jenkins and see if that works but a cleaner approach is to use a plugin for this. in this case the config fileprovider plugin . after adding this plugin to jenkins you can define any config file in it, in our case a maven settings.xml file:
screen shot 2014-05-10 at 10.21.03

the final step is to make the jenkins release build to use this settings.xml file. you can so this like this:
screen shot 2014-05-12 at 17.59.55

now i can run the maven release build in jenkins like it runs on my local machine.


Apache Maven Jenkins (software) Release (computing)

Published at DZone with permission of $$anonymous$$. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Publish Artifacts to Maven Central
  • Mulesoft 4: Continuous Delivery/Deployment With Maven
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]
  • Solid Testing Strategies for Salesforce Releases

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: