Friday, 28 July 2017

Salesforce Jenkins Ant deployment Steps

/**********************************************************************

**********************************************************************/


PREREQUSITES
*************************************************
1. JDK
2. JRE
3. Force.com Migration tool
4. Apache Ant

*************************************************

A. Install ANT
*************************************************
Step 1: Download JRE 6 : Verify the correct installation by executing the following command: java -version
Step 2: Download Ant(version 1.6 or higher) zip file from http://ant.apache.org/bindownload.cgi
Step 3: Download Force.com Migration Tool zip folder from Salesforce Org for which the path is as follows: Develop->Tools->Force.com Migration Tools
Step 4: Copy the "ant-salesforce.jar" file from the above extracted folder and paste it in the lib directory of the installed Ant folder.
Step 5: Set the environment Variables as follows:
        ->System Variables->new>  Variable Name: ANT_HOME
                         Variable Value: C:\Program Files\apache-ant-x.xx.x
->System Variables->new>  Variable Name: JAVA_HOME
                         Variable Value: C:\Program Files\Java\jdk_x.xx.x

        ->System Variables->edit->PATH ->
                                  In PATH, add %JAVA_HOME%\bin and %ANT_HOME%\bin
..... %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;....;%JAVA_HOME%\bin;%ANT_HOME%\bin; .....

Step 6: Verify if 'C:\Program Files\Java\jdk_x.xx.x\lib' contains 'Tools.jar' file.
Step 7: Run the following command in cmd to verify the correct installation of ANT : ant -version

OPTIONAL:
Step 8: have build.xml and build.properties at the src level of moving source file.(ANT checks package.xml of the project src file to know what all things have to migrate).


*************************************************

B. Install Jenkins (on Windows)
*************************************************
If you're running on Windows you might want to run Jenkins as a service so it starts up automatically without requiring a user to log in. Install jenkins using windows package (http://jenkins-ci.org/) or using java web archive (.war) file.
You need to start jenkins engine if you've installed using the .war file. To do this, open command prompt and navigate to the folder where 'jenkins.war' file is located. run the following command:

C:/...>java -jar jenkins.war

If you've installed using windows installer, there's no need to start jenkins engine.
To run Jenkins, open your browser and connect to 'localhost:8080'



*************************************************

C. Configure Jenkins
*************************************************
Once your jenkins is up, goto jenkins > manage jenkins > configure system
Update the JDK and ANT sections with their respective version and path.



*************************************************

D. Configure Jobs
*************************************************
1. Click on 'New Item' and enter item name. Select 'free-style software project'. click 'OK'
2. Goto 'Build' section in the configuration page. Select Ant version.
3. In the Targets field, enter the library and property file path.
Eg:
-lib
D:\...\apache-ant-1.9.2\lib/ant-salesforce.jar
-propertyfile
D:\...../build.properties

4. Click on advanced button. In the 'Build File' field, enter the the path Ant's for build.xml
D:\.....\build.xml

5. In the 'Proprties' field, enter the salesforce parameters used by Ant in build.xml

sf.username = user@xyz.com
sf.password = PasswordSecurityToken
sf.serverurl = login.salesforce.com
sf.checkOnly = false
sf.runAllTests = false
sf.logLevel = None

6. Click Save. Your deployment job is ready to go! Click 'Build Now' to run the deployment job.
*************************************************