Thursday 9 April 2015

C# - Integrating Nant with Jenkins Continuous Integration tool.

Jenkins is open source tool to perform continuous integration.
For starting the Jenkins server, java should be installed and configured. Since jenkins server runs on Java.

Prerequisite:
1. Java is already installed.
    click url https://java.com/en/download/ for java installation.

2. Java build path is already set.
   click url https://docs.oracle.com/javase/tutorial/essential/environment/paths.html for setting the build path

3. Nant is already configured.
    click url http://automation-home.blogspot.com/2015/04/csharp-nant-configuration-and-executing-nant-echo-message.html Nant configuration.

Below steps demonstrates integrating Nant with Jenkins Continuous Integration tool.  
 
1. Download Jenkins war from url: https://jenkins-ci.org/

2. Copy the 'jenkins.war' to some folder ex: 'C:\Jenkins'

3. Open the command prompt and navigate to the folder where Jenkins war is present.

4. Run the command 'java -jar jenkins.war' in command prompt.


5. Open the browser and type http://localhost:8080/


6. Click 'Manage Jenkins' link.

7. Click 'Manage Plugins' link.

8. Click 'Available' tab.

9. 'Available' tab is opened.

    Select 'NAnt' plugin and click button 'Download now and install after restart'.


10. Restart the System.

     Start jenkins(i.e. 'java -jar jenkins.war' ) after restarting the system.

11. Go to ‘Manage Jenkins’ -> ‘Manage Plugins’ -> ‘Installed‘ tab.

12. Now go to the Jenkins Dashboard screen.


13. Create New Job.


14. Enter item name ex: 'SampleTestSolution', Select 'Freestyle project' and click on 'OK' button.
 



15. Specify Nant Build file and target details and click on 'Save' button.


"HelloWorld.build" file:
------------------------
<?xml version="1.0" encoding="utf-8" ?>
<project name="HelloWorld" default="go">
<property name="message" value="Hello World from praveen.!"/>
   <target name="go">
       <echo message="${message}"/>
  </target>
</project>

16. Navigate to Home page and run the build.

17. See the results in Console.  


Note: The above approach is demonstrated by executing the simple build file(i.e. with echo message), with out any scheduling configuration in Jenkins.

No comments:

Post a Comment