简体   繁体   中英

Generating a jar on svn using jenkins integration of ant project

I have created a java project and generated a ant build file for the project. The ant file basically consist of code to generated jar from the java files. I project is stored in svn. So I am using the subversion option to mention the repository url. What i want is after successful build in jenkins the jar file should get geneated in svn location where the project is currently present. After building the project in jenkins is can see the build is successful but the jar is not getting generated on the svn repository. Please help me configure jenkins in such a way that after build jar files gets generated on svn location.

When you use Jenkins to build the project, the first thing Jenkin does is checking out your code from svn to Jenkins workspace. Build will happen from the workspace and artifacts (jar/war/ear) will be created in the workspace.

Where is my Jenkins workspace?

You can mention custom workspace for the job from Configure Job >> Advanced Project Options .

In case you are not using this option, by default the workspace will be under Jenkins_Home Directory. Jenkins_home/jobs/my_job/workspace/

Further it is not a good practice to add the artifacts back to svn.

use svn task of ant to commit the jar created by your build.

See below Snippet

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml"
 classpathref="svnant.classpath"/>

<svnSetting id="svn.settings" username="${svn.username}" password="${svn.pw}" 
javahl="false" svnkit="true" failonerror="true"/>

<target name="commit">
   <svn refid="svn.settings">
        <commit file="${webcontent}/version.properties"
            message="commit version from build.xml by ${user.name}"
        />
    </svn>

</target>

Just Pass your Username and Password

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM