I'm setting up the build pipeline in VSTS (Visual Studio Team Services), and I'm not able to pass a variable to the build. I don't know what the syntax should I use actually to get the variable in the build I guess. I created the variable in the VSTS: VSTS variablesI use standard build.xml file:

<project name="Sample usage of Salesforce Ant tasks" default="deployCodeAndRunTests" basedir="." xmlns:sf="antlib:com.salesforce">

<property file="build.properties"/>
<property environment="env"/>

<!-- Setting default value for username, password and session id properties to empty string 
     so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
     will be treated literally.
<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
<condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
<condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

<taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
        <pathelement location="ant-salesforce.jar" />           

<!-- Deploy code and run tests.  If test fails, rollback deploy. -->
<target name="deployCodeAndRunTests">

Any suggestion on how to get the variables to the build?

  • 1
    You might get better answers asking on stackoverflow. This seems like more of a question about the underlying software, rather than salesforce. They even have a tag for it vsts Aug 28, 2018 at 16:49

1 Answer 1


To run the ant build with the parametrs from VSTS you need set them with the property task in build.xml

<property name="sf.username" value="${sfUsername}"/>
<property name="sf.password" value="${sfPassword}"/>
<property name="sf.serverurl" value="${sfServerurl}"/>    
<property name="sf.testLevel" value="${sfTestLevel}"/>

Then, when setting up the build in VSTS, you set it to run with parameters, where you assign the variables defined in VSTS. To run the ant build with parameters you use the Options: VST Ant build job

  • How do you pass the VSTS variables to build.properties file? I'm trying to avoid having username/password on it.
    – Rodrigo
    Aug 27, 2019 at 4:01

Not the answer you're looking for? Browse other questions tagged .