Build javahelloworld with jenkins

Source: Internet
Author: User

Note: Jenkins supports distributed job running through Master/Slave. javahelloworld runs on the master, that is, the machine where Jenkins is located.

 

Java helloworldProgram

Ant build Script: C: \ javahelloworld \ build. xml

< Project Name = "Helloworld" Basedir = "." Default = "Main" >

<PropertyName= "Src. dir"Value= "Src"/>

< Property Name = "Build. dir" Value = "Build" />
< Property Name = "Classes. dir" Value = "$ {Build. dir}/classes" />
< Property Name = "Jar. dir" Value = "$ {Build. dir}/jar" />

property name =" Main-class " value =" oata. helloworld " />

<TargetName= "Clean">
<DeleteDir= "$ {Build. dir }"/>
</Target>

< Target Name = "Compile" >
< Mkdir Dir = "$ {Classes. dir }" />
< Javac Srcdir = "$ {SRC. dir }" Destdir = "$ {Classes. dir }" />
</ Target >

< Target Name = "Jar" Depends = "Compile" >
< Mkdir Dir = "$ {Jar. dir }" />
< Jar Destfile = "$ {Jar. dir}/$ {ant. Project. name}. Jar" Basedir = "$ {Classes. dir }" >
< Manifest >
< Attribute Name = "Main-class" Value = "$ {Main-class }" />
</ Manifest >
</ Jar >
</ Target >

Target name =" run " depends =" jar " >
JAVA jar =" $ {jar. dir}/$ {ant. project. name }. jar " fork =" true " />
Target >

<TargetName= "Clean-build"Depends= "Clean, Jar"/>

<TargetName= "Main"Depends= "Clean, run"/>

</Project>

 

Java helloworld: C: \ javahelloworld \ SRC \ oata \ helloworld. Java

Package oata;

Public class helloworld {
Public static void main (string [] ARGs ){
System. Out. println ("Hello World ");
}
}

 

2. Start Jenkins and create a job to run javahelloworld

1) Start Jenkins at Port 8000:

 

 

2) create a javahelloworld job

Open http: // localhost: 8000 in IE,

Click the new job link to create a job for javahelloworld. The configuration of the compiled job is as follows:

Note that Jenkins has installed SVN plugin by default.

 

 

3) run the javahelloworld job

Go to the home page of javahelloworld and click the build now link to build. After building, you can view all the build history on this home page, as shown below:

 

You can also click the link of a build to view the detailed logs of a build, as shown below:

 

 

Refer:

Http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.