DZone
DevOps Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > 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 · DevOps Zone · Interview
Like (0)
Save
Tweet
11.26K 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

  • How to Make Git Forget a Tracked File Now in .gitignore
  • Creating an Event-Driven Architecture in a Microservices Setting
  • How to Build Security for Your SaaS User Communications
  • Modern Application Security Requires Defense in Depth

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • 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:

DZone.com is powered by 

AnswerHub logo