Total Pageviews

Sunday, 5 February 2017

Project creation in Jenkins !!!

In the previous post, we have setup the Jenkins Master/Slave environment. In this post, lets see the project creation and the automation of build process along with the Continuous Integration.

Most important tabs in Jenkins UI.



Click on the "create new jobs"....


Choose a name for your project,


We selected Free style, because it gives platform independent template for our project...
We can restrict where this project can run .... I selected my Windows_Slave....



We have 5 main categories while building a template for out project....
First of all, let us provide details related to our SCM..



Build Triggers are something which are responsible to build our projects in time intervals..

Build Periodically: Allows us to schedule timings (as per cron schedule) to trigger our build..
Build after other project: It restricts a build that it should be build only if a particular build is done..
Poll SCM: Our SCM will poll and (if any changes done to our SVN/Git) then triggers our build.


In Build environment, we can provide our command for the build process....


Different options for build step...


Different options for Post build actions....
Post build actions: These actions decide what to be performed once a build is created...


I chose to "Archive the artifacts"...



Once we are good with the Configuration part, we can save and apply....



Sample project which I built during my MAVEN post, I committed to my Git SCM...


Click on Build Now....


Console output:


It is failed, saying mvn is not recognized as internal or external command...
In the Configuration part, we already set the Home for Maven.


We need to add the MAVEN tool....



Now it is enabled in configuration.. choose the tool location...



Let's try building our project again....



This time it is a SUCCESS...


Even the Post-Build job is executed successfully, we can see the archived package file java_app.1.0.jar is generated...


As you can see, I failed 6 times. It is so important to maintain required plugins, tools and Home locations...

One more important thing which comes under Jenkins Administration:
                                  Prepare for Shutdown...
In case of any maintenance activities we can create an alarm using this option.... shows a message and restricts any new builds till we cancel it.

################################################################################

Jenkins Master/Slave Environment !!!

Jenkins is a Open source Java based program used to automate the Continuous Integration process of Project builds. In real time, every project will be having different phases like Source Code development, Build process, Continuous Integration and Continuous Delivery.

For more productivity, automation plays most important role. To automate build process, many Organizations make use of different tools like ANT, Maven... Similarly for automating Integration process, we use Jenkins tool. In this post, I am going to discuss about the setup of Jenkins Master/Slave environment and how to create/build projects.

Jenkins is developed by Kohsuke Kawaguchi, it is exact copy of Hudson. After acquisition of SUN by Oracle, Hudson rights moved to Oracle and then its not completely Open source. So, Kohsuke developed Jenkins from Hudson and released it as Open Source.

In Jenkins, to balance the load of jobs we setup master/slave environment. So that the jobs will be shared among the master and its slave nodes. It is better to leave Master node for Jenkins Administration and distribute the jobs among slave nodes.

Installation is so simple, just copy the war file to /home/ubu/apache-tomcat-7.0.75/webapps and once tomcat started, Jenkins will be deployed.


root@ubuntu-kvm:/home/ubu/apache-tomcat-7.0.75# cd webapps/
root@ubuntu-kvm:/home/ubu/apache-tomcat-7.0.75/webapps#
root@ubuntu-kvm:/home/ubu/apache-tomcat-7.0.75/webapps# ls
             docs  examples  git  git.war  host-manager  jenkins  jenkins.war  manager  ROOT
root@ubuntu-kvm:/home/ubu/apache-tomcat-7.0.75/webapps#

Open in the browser,


Copy the password from given location,


To create admin user,


To manage Jenkins nodes,


Choose a name and select permanent agent,



The red X mark indicates to launch the agent in our slave node...
There are different launch methods, but I prefer launching via web start....


Go to Manage Jenkins ---> Configure Global System...


Select "Random", TCP port for JNLP agents...


Now, Launch agent via Java Web start is enabled in launch method...


Click on Launch...


Click on Run, it will start the agent in Slave node...


Agent started....


Similarly we can create different slave nodes and we can launch the agent in different ways....

################################################################################