Sunday, October 14, 2012

Install Jenkins on Tomcat

Hi All,

To install jenkins on tomcat server,

1.Download apache tomcat
2.Download jenkins.war
3.Copy jenkins.war in  apache-tomcat-*.0.**/webapps/ foler
4.Navigate to  http://localhost:8080/jenkins
5.You can see jenkins installed on Tomcat.

Thursday, October 4, 2012

Link to store the subversion credentials in jenkins

When we have configured master-slave connection,we need to store svn credentials in both master and slave .Link appears to enter the credentials on master for jobs which runs on master,but link doesn't appears for the jobs tied to slave.Hence ,Auhentication failed error appears and svn checkout cannot be done.

Below is the link which will help you to store the svn credentials on any jenkins .

If  your jenkins is on localhost:8080 then,



If you need to setup credentials on jenkins which is deployed on any webserver , then

http://machinename:port/jenkins/scm/SubversionSCM/enterCredential
 where port is webserver's port number

Wednesday, October 3, 2012

Calling a java class as ant target

Here is the way to do it

classname: is filename of java :Ex: AutomationFileSequence
 arg: Any arguments if required to run the class needs to be mentioned here.

<target name="run_PostData" >
  <java fork="false" failonerror="yes" classname="com.qa.automation.main.AutomationFileSequence" classpathref="classpath"> 
            <arg line="${basedir}/Automation_PostData.properties"/>
    <arg line="PostData"/>
            </java>
            </target>

Starting and stopping selenium server through ant

Here is the way to do it.

Start selenium hub:

<target name="startServerhub">
        <echo>Starting Selenium Server...</echo>
        <java jar="${lib.dir}/selenium-server-standalone.jar" fork="true" spawn="true">
            <arg line="-port ${selenium.port} -trustAllSSLcertificates"/>
            <arg line="-log log.txt"/>   
            <arg value="-role"/>
            <arg value="hub"/>
        </java>
    </target>

Start selenium RC:

<target name="startServerRC" depends="startServerhub">
        <echo>Starting Selenium Server...</echo>
        <java jar="${lib.dir}/selenium-server-standalone.jar" fork="true" spawn="true">
            <arg line="-port 5555"/>
            <arg line="-log log.txt"/>   
            <arg line="-firefoxProfileTemplate"/>
            <arg value="${lib.dir}/ff_profile"/>
            <arg line="-userExtensions"/>
                <arg value="${lib.dir}/user-extensions.js"/>
            <arg line="-role node"/>
            <arg line="-hub http://localhost:4444/grid/register "/>
            <!--<arg line="-maxSession 10"/>
            <arg line="-maxInstances=10"/>-->
        </java>
    </target>


Now ,save the targets in the file build.xml .navigate to the folder through cmd prompt and call



 ant startServerRC

which will internally call startServerhub,since startServerRC depends on startServerhub.



Stop selenium :

<target name="stop-selenium" description="stop selenium server">
        <echo>Stopping selenium server</echo>
        <get taskname="selenium-shutdown" dest="result.txt" ignoreerrors="true"
             src="http://localhost:${selenium.port}/selenium-server/driver/?cmd=shutDownSeleniumServer"/>
    </target>


To stop selenium, call  : ant stop-selenium.

Sample Ant Script for running targets parallel and sequential

Recently ,I faced a challenge for making one target which can run the entire suite with lot of module dependencies.This was resolved with the help of ant targets: sequential and parallel.


Requirement :
I need to run the following sequetially

1.compile target
2. run and run_psdata targets paralelly
3.run_PreData,run_DFPPulls,run_AdTechPulls.... parallelly
4.run_PostData,run_Sales parallely
5.run_Administration,run_E2EPartner360,..... parallelly
6.run_Alerts,run_CustomFields  parallelly
7.Stop selenium

Below is the code to do all the above steps sequentially


<target name="CItarget">    
        <sequential>
            <antcall target="compile"/>
            <parallel>
              <antcall target="run"/>
              <antcall target="run_PSDATA"/>
            </parallel>
             <parallel>
                <antcall target="run_PreData"/>
                <antcall target="run_DFPPulls"/>
                <antcall target="run_AdTechPulls"/>
                <antcall target="run_AppnexusPulls"/>
                <antcall target="run_FTPPulls"/>
                <antcall target="run_OASPulls"/>
                <antcall target="run_GDFPPulls"/>
                <antcall target="run_FreewheelPulls"/>
                <antcall target="run_ThirdPartyPulls"/>
            </parallel>
    <parallel>
        <antcall target="run_PostData"/>
        <antcall target="run_Sales"/>
    </parallel>
            <parallel>
                <antcall target="run_Administration"/>
                <antcall target="run_E2EPartner360"/>
                <antcall target="run_Finance"/>
                <antcall target="run_Loaders"/>
                <antcall target="run_Accounts"/>
                <antcall target="run_Adops"/>
            </parallel>
            <parallel>
                 <antcall target="run_Alerts"/>
                <antcall target="run_CustomFields"/>
            </parallel>
            <antcall target="stop-selenium"/>
       </sequential>
    </target>