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 Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Exporting MAVEN_OPTS not working for Freestyle Jenkins Projects

Exporting MAVEN_OPTS not working for Freestyle Jenkins Projects

James Betteley user avatar by
James Betteley
·
Nov. 10, 11 · Interview
Like (0)
Save
Tweet
Share
11.48K Views

Join the DZone community and get the full member experience.

Join For Free

i’m running jenkins version 1.428 and i have a “freestyle” project. the aim of this project is to upload a large tar.gz file to an artifactory repository. the team are using maven so we started out by looking at using maven to do the deployment. it seems simple enough – you just choose “invoke top-level maven targets” and add the usual maven deploy details here, like so:

the trouble is, because the tar is so large (126mb in this instance), it fails with a java heap space issues (out of memory exception). so, it would be very tempting to try to increase the maven_opts by passing it via the jvm options, as shown below:

sadly, this doesn’t work. it fails with an ugly error saying maven_opts isn’t recognised, or some such thing.

now, in an attempt to be clever, we thought we could simply execute a shell command first, and get that to set the maven_opts, like so:

good ideah huh? yeah, well it didn’t work :-(

it looks like there’s a general issue with setting maven_opts for freestyle projects in jenkins version 1.428 – see here for details.

workarounds:

there’s actually a couple of workarounds. firstly, you can run maven via the shell execution command, and explicitly pass the maven_opts value:

this actually works fine, and is the preferred way of doing it in our case.

the other option is to use ant to do the deployment – this somehow seems to use a lot less memory and doesn’t fail quite so easily. also, you don’t have this issue with the maven_opts being passed as you can set it directly in the ant file. here’s the ant file i created (i also created a very basic pom.xml):

<project name=”artifactory_deploy” basedir=”.” default=”deploy_to_repo” xmlns:artifact=”antlib:org.apache.maven.artifact.ant”>
<description>sample deploy script</description>
<taskdef resource=”net/sf/antcontrib/antcontrib.properties”/>

<property name=”to.name” value=”myrepo” />
<property name=”artifactory.url” value=”http://artifactory.mycompany.com”/>
<property name=”jar.name” value=”massive.tar.gz”/>

<target name=”deploy_to_repo” description=”deploy build to repo in artifactory” >
<artifact:pom id=”mypom” file=”pom.xml” />
<artifact:deploy file=”${jar.name}”>
<remoterepository url=”${artifactory.url}/${to.name}” />
<pom refid=”mypom” />
</artifact:deploy>
</target>

</project>



source : http://jamesbetteley.wordpress.com/2011/11/10/exporting-maven_opts-not-working-for-freestyle-jenkins-projects/
Jenkins (software)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • All the Cloud’s a Stage and All the WebAssembly Modules Merely Actors
  • Software Maintenance Models
  • Distributed Tracing: A Full Guide
  • Spinnaker vs. Argo CD: Best Tools for Continuous Delivery

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: