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