Ant 将变量从VSTS build传递到build.xml
我正在VSTS(VisualStudioTeamServices)中设置构建管道,但无法将变量传递给构建。我不知道应该使用什么语法来获取构建中的变量。我在VST中创建了变量: 我使用标准build.xml文件:Ant 将变量从VSTS build传递到build.xml,ant,azure-devops,salesforce,azure-pipelines,Ant,Azure Devops,Salesforce,Azure Pipelines,我正在VSTS(VisualStudioTeamServices)中设置构建管道,但无法将变量传递给构建。我不知道应该使用什么语法来获取构建中的变量。我在VST中创建了变量: 我使用标准build.xml文件: <project name="Sample usage of Salesforce Ant tasks" default="deployCodeAndRunTests" basedir="." xmlns:sf="antlib:com.salesforce"> <pr
<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">
<classpath>
<pathelement location="ant-salesforce.jar" />
</classpath>
</taskdef>
<!-- Deploy code and run tests. If test fails, rollback deploy. -->
<target name="deployCodeAndRunTests">
<sf:deploy
username="${sf.username}"
password="${sf.password}"
sessionId="${sf.sessionId}"
serverurl="${sf.serverurl}"
maxPoll="${sf.maxPoll}"
deployRoot="..\src"
testLevel="NoTestRun"
rollbackOnError="true"
logType="Detail"/>
</target>
关于如何将变量获取到构建中的任何建议?要使用VSTS中的参数运行ant构建,您需要使用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}"/>
然后,在设置内置VST时,将其设置为使用参数运行,并在其中分配VST中定义的变量。要使用参数运行ant构建,请使用选项
:
您看过文档了吗?你可以查一下,我确实查过文件,但没有找到答案。可能我不知道我到底在寻找什么。
在Ant中几乎总是毫无意义的,因为属性是不可变的。只需使用属性
任务设置默认值。命令行属性作为-Dkey=value
传递。您好@mascot,您知道如何将值传递到build.properties文件吗?即使我能够将变量值传递给脚本,它仍会在build.properties中搜索值。感谢共享,您可以将自己的回复标记为答案。您好@mascot,您知道如何在“build.properties”文件中引用这些变量吗?#指定所需Salesforce组织的登录凭据sf.username=sf.password=sf.serverurl=sf.maxPoll=2000