简体   繁体   English

使用ant项目的jenkins集成在svn上生成jar

[英]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. 我创建了一个Java项目,并为该项目生成了一个ant构建文件。 The ant file basically consist of code to generated jar from the java files. ant文件基本上由从Java文件生成jar的代码组成。 I project is stored in svn. 我的项目存储在svn中。 So I am using the subversion option to mention the repository url. 因此,我正在使用subversion选项提及存储库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. 我想要的是在jenkins中成功构建之后,jar文件应该在当前项目所在的svn位置生成。 After building the project in jenkins is can see the build is successful but the jar is not getting generated on the svn repository. 在jenkins中构建项目后,可以看到构建成功,但是在svn存储库上未生成jar。 Please help me configure jenkins in such a way that after build jar files gets generated on svn location. 请帮助我配置jenkins,以便在生成svn位置的生成jar文件之后。

When you use Jenkins to build the project, the first thing Jenkin does is checking out your code from svn to Jenkins workspace. 当您使用Jenkins构建项目时,Jenkin要做的第一件事就是将代码从svn检出到Jenkins工作区。 Build will happen from the workspace and artifacts (jar/war/ear) will be created in the workspace. 构建将从工作空间进行,并且将在工作空间中创建工件(jar / war / ear)。

Where is my Jenkins workspace? 我的Jenkins工作区在哪里?

You can mention custom workspace for the job from Configure Job >> Advanced Project Options . 您可以从“ 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目录下。 Jenkins_home/jobs/my_job/workspace/

Further it is not a good practice to add the artifacts back to svn. 此外,将工件添加回svn也不是一个好习惯。

use svn task of ant to commit the jar created by your build. 使用ant的svn任务来提交由您的构建创建的jar。

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 只需输入您的用户名和密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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