Hi,
I am using Jenkins with Ant for Salesforce Deployments. Although i am able to deploy using Ant only through the command prompt. But when i am using Jenkins with Ant, gives an error saying Ant.bat is not found by Jenkins.
In Jenkins, i have added Invoke Ant and targets as ‘deployCode’.
Could please someone tell me why jenkins is not able to understand the Path
Jenkins has a concept of “tools” that include common build tools like Apache Ant, Apache Maven, Gradle and Java versions. In “Manage Jenkins” → “Tools” you’ll find the configuration page.
Darin Pope has created a video that shows how to configure a JDK tool. Similar steps are needed to configure Apache Ant as a Jenkins tool
Hi @MarkEWaite ,
In this video there requires installation of Ant inside Jenkins. The Ant is installed in my system. Also Jenkins is installed in the same system. So, i am giving the xml and build file path inside Jenkins → System → Global Properties ->Environment Variables as shown below:
Also, the Ant build steps are added as below:
Target: deployCode
Build File: C:\ANT_HOME\apache-ant-1.10.14\sample
Properties: C:\ANT_HOME\apache-ant-1.10.14\sample
After build option, i am getting the error as below
Commit message: “Update MyApexForAccountContact.cls - 20May -1”
git.exe rev-list --no-walk af08783fdced252b98e30b5b716ab8f6d64c13e2 # timeout=10
[apache-ant-1.10.14] $ cmd.exe /C “ant.bat -file sample -DC=ANT_HOMEapache-ant-1.10.14sample deployCode && exit %%ERRORLEVEL%%”
Build step ‘Invoke Ant’ marked build as failure
Finished: FAILURE
What am i doing here? Should i again install Ant inside Jenkins. Also, without Jenkins, i am able to upload all the source to target salesforce Org. using only Ant tool from cmd - prompt
Thanks,
Syam
You can define an Ant tool in Jenkins that downloads and installs Ant when needed or you can define an Ant tool in Jenkins that references the existing Ant installation. Both techniques work and there are situations where one is preferred and situations where the other is preferred.
I use the following configuration as code definition for the Ant tool on my Jenkins controller:
tool:
ant:
installations:
- name: "ant-latest"
properties:
- installSource:
installers:
- command:
command: "echo 'Using pre-installed ant for jagent and not Windows'"
label: "jagent && !windows"
toolHome: "/home/jagent/tools/apache-ant-1.10.14"
- batchFile:
command: "echo 'Using pre-installed ant for Windows'"
label: "windows"
toolHome: "C:\\tools\\apache-ant-1.10.14"
- zip:
subdir: "apache-ant-1.10.14"
url: "https://home.markwaite.net/~mwaite/ant/apache-ant-1.10.14-bin.zip"
That defines 3 different installers for a tool named “ant-latest”. The first installer is invoked on agents that have the label jagent
and do not have the label windows
. The second installer is invoked on agents that have the label windows
. The third installer is invoked on agents that do not use one of the first two installers.
That sequence of installers provides first priority to the already installed version and has a fallback installer that uses a copy that is local on my network. I intentionally do not install from Apache.org because I don’t want to use their bandwidth or have my builds require that their service is available.