我目前正在努力完成关于“Deploying with the Force.com Migration Tool (ANT)”的SalesForce.com教程。
我确定我错过了一些东西......可能是因为我对Ant的知识和经验非常有限。
我创建了一个新的Java Project并将Sample目录从salesforce_ant_20.0.zip
复制到其中。我修改了build.properties并在eclipse中运行build.xml
来测试它。一切都运转正常。
因此,我在src
目录中创建了Sandbox1,并将package.xml
从我的SFDC项目复制到其中。然后我将build.properties和build.xm
l从sample
复制到src
目录中。现在,当我开始运行build.xml
时,它抱怨deployRoot mypkg
不存在。我将deployRoot更改为Sandbox1
并尝试再次测试。结果如下:
Buildfile: D:\education\sfdc\Deploy\src\build.xml
test:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request Id for the current deploy task: 04sA0000002GwsGIAS
[sf:deploy] Waiting for server to finish processing the request…
[sf:deploy] Request Status: Completed
BUILD FAILED
D:\education\sfdc\Deploy\src\build.xml:14: FAILURES:
Error: package.xml(Account):An object ‘Account’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(AccountContactRole):An object ‘AccountContactRole’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Activity):An object ‘Activity’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Asset):An object ‘Asset’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Campaign):An object ‘Campaign’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(CampaignMember):An object ‘CampaignMember’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Case):An object ‘Case’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(CaseContactRole):An object ‘CaseContactRole’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Contact):An object ‘Contact’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(ContentVersion):An object ‘ContentVersion’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Contract):An object ‘Contract’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(ContractContactRole):An object ‘ContractContactRole’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Event):An object ‘Event’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Idea):An object ‘Idea’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Lead):An object ‘Lead’ of type CustomObject was named in package.xml, but was not found in zipped directory
Error: package.xml(Opportunity):An object ‘Opportunity’ of type CustomObject was named in package.xml, but was not found in zipped directory
我认为这有帮助:
(1)/src/sandbox1
仅包含来自Eclipse中不同功能的SalesForce项目的文件package.xml
。
这个文件说:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>CustomApplication</name>
</types>
<types>
<members>*</members>
<name>CustomLabels</name>
</types>
<types>
<members>*</members>
<members>Account</members>
<members>AccountContactRole</members>
<members>Activity</members>
<members>Asset</members>
<members>Campaign</members>
<members>CampaignMember</members>
<members>Case</members>
<members>CaseContactRole</members>
<members>Contact</members>
<members>ContentVersion</members>
<members>Contract</members>
<members>ContractContactRole</members>
<members>Event</members>
<members>Idea</members>
<members>Lead</members>
<members>Opportunity</members>
<members>OpportunityContactRole</members>
<members>OpportunityLineItem</members>
<members>PartnerRole</members>
<members>Product2</members>
<members>Site</members>
<members>Solution</members>
<members>Task</members>
<members>User</members>
<members>UserLicense</members>
<name>CustomObject</name>
</types>
<types>
<members>*</members>
<name>CustomObjectTranslation</name>
</types>
<types>
<members>*</members>
<name>CustomPageWebLink</name>
</types>
<types>
<members>*</members>
<name>CustomSite</name>
</types>
<types>
<members>*</members>
<name>CustomTab</name>
</types>
<types>
<members>*</members>
<name>DataCategoryGroup</name>
</types>
<types>
<members>unfiled$public</members>
<members>unfiled$public/Large_Invoice_Template</members>
<members>unfiled$public/MarketingProductInquiryResponse</members>
<members>unfiled$public/SUPPORTSelfServiceNewCommentNotificationSAMPLE</members>
<members>unfiled$public/SUPPORTSelfServiceNewUserLoginInformationSAMPLE</members>
<members>unfiled$public/SUPPORTSelfServiceResetPasswordSAMPLE</members>
<members>unfiled$public/SalesNewCustomerEmail</members>
<members>unfiled$public/SupportCaseAssignmentNotification</members>
<members>unfiled$public/SupportCaseCreatedPhoneInquiries</members>
<members>unfiled$public/SupportCaseCreatedWebInquiries</members>
<members>unfiled$public/SupportCaseResponse</members>
<members>unfiled$public/SupportEscalatedCaseNotification</members>
<members>unfiled$public/SupportEscalatedCaseReassignment</members>
<members>unfiled$public/SupportSelfServiceNewLoginandPassword</members>
<members>unfiled$public/SupportSelfServiceResetPassword</members>
<name>EmailTemplate</name>
</types>
<types>
<members>*</members>
<name>HomePageComponent</name>
</types>
<types>
<members>*</members>
<name>HomePageLayout</name>
</types>
<types>
<members>*</members>
<name>Layout</name>
</types>
<types>
<members>*</members>
<name>Letterhead</name>
</types>
<types>
<members>*</members>
<name>Profile</name>
</types>
<types>
<members>ApexDevNet</members>
<name>RemoteSiteSetting</name>
</types>
<types>
<members>unfiled$public</members>
<name>Report</name>
</types>
<types>
<members>*</members>
<name>ReportType</name>
</types>
<types>
<members>*</members>
<name>Scontrol</name>
</types>
<types>
<members>*</members>
<name>StaticResource</name>
</types>
<types>
<members>*</members>
<name>Workflow</name>
</types>
<version>20.0</version>
</Package>
来自基于Java / Ant的Force.com迁移工具的build.xml
说:
<property file="build.properties"/>
<property environment="env"/>
<!-- Test out deploy and retrieve verbs for package 'mypkg' -->
<target name="test">
<!-- Upload the contents of the "mypkg" package -->
<sf:deploy
username="${sf.username}"
password="${sf.password}"
serverurl="${sf.serverurl}"
deployRoot="mypkg"
/>
<mkdir dir="retrieveOutput"/>
<!-- Retrieve the contents into another directory -->
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveOutput" packageNames="MyPkg"/>
</target>
<!-- Retrieve an unpackaged set of metadata from your org -->
<!-- The file unpackaged/package.xml lists what is to be retrieved -->
<target name="retrieveUnpackaged">
<mkdir dir="retrieveUnpackaged"/>
<!-- Retrieve the contents into another directory -->
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveUnpackaged" unpackaged="unpackaged/package.xml"/>
</target>
<!-- Retrieve all the items of a particular metadata type -->
<target name="bulkRetrieve">
<sf:bulkRetrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" metadataType="${sf.metadataType}" retrieveTarget="retrieveUnpackaged"/>
</target>
<!-- Retrieve metadata for all the packages specified under packageNames -->
<target name="retrievePkg">
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveOutput" packageNames="${sf.pkgName}"/>
</target>
<!-- Deploy the unpackaged set of metadata retrieved with retrieveUnpackaged -->
<target name="deployUnpackaged">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="retrieveUnpackaged"/>
</target>
<!-- Deploy a zip of metadata files to the org -->
<target name="deployZip">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" zipFile="${sf.zipFile}" pollWaitMillis="1000"/>
</target>
<!-- Shows deploying code & running tests for code in directory -->
<target name="deployCode">
<!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="codepkg">
<runTest>SampleDeployClass</runTest>
</sf:deploy>
</target>
<!-- Shows removing code; only succeeds if done after deployCode -->
<target name="undeployCode">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="removecodepkg"/>
</target>
<!-- Shows retrieving code; only succeeds if done after deployCode -->
<target name="retrieveCode">
<!-- Retrieve the contents listed in the file codepkg/package.xml into the codepkg directory -->
<sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="codepkg" unpackaged="codepkg/package.xml"/>
</target>
<!-- Shows deploying code, running all tests, and running tests (1 of which fails), and logging. -->
<target name="deployCodeFailingTest">
<!-- Upload the contents of the "codepkg" package, running all tests -->
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="codepkg" runAllTests="true" logType="Debugonly"/>
</target>
<!-- Shows check only; never actually saves to the server -->
<target name="deployCodeCheckOnly">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="codepkg" checkOnly="true"/>
</target>
<!-- Retrieve the information of all items of a particular metadata type -->
<target name="listMetadata">
<sf:listMetadata username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" metadataType="${sf.metadataType}"/>
</target>
<!-- Retrieve the information on all supported metadata type -->
<target name="describeMetadata">
<sf:describeMetadata username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}"/>
</target>
知道我做错了什么或如何解决它?
答案 0 :(得分:0)
错误表明您的package.xml引用了目录结构中没有相应文件的组件。从package.xml中删除这些引用或添加缺少的自定义对象文件。
如果这不起作用,您是否可以编辑您的问题以包含Sandbox1的目录列表?
答案 1 :(得分:0)
您的构建文件默认从您的计算机“部署”到服务器。这仅适用于您的计算机上有内容的情况。首先运行“retrieveUnpackaged”。这将获取package.xml文件中指定的服务器上的所有内容。然后,您可以修改结果并进行部署。
就个人而言,我只使用您在上面显示的package.xml类型进行备份。我保留一个package.xml文件,列出所有内容(使用“*”加标准对象)来检索整个内容。我从不使用这些结果在服务器上进行更改,因为最终的“部署”将需要永远。
相反,创建一个package.xml文件以获取您需要处理的文件。然后更改代码,然后使用这个较小的软件包进行部署。
答案 2 :(得分:0)
您的包文件使用旧版API:
<version>20.0</version>
我非常确定该版本不支持您在那里所做的一切。
快速编辑:36是我认为的当前版本。 编辑2:男人这是一个老问题,我是怎么来到这里的?
答案 3 :(得分:0)
为时已晚。但是我认为这里的问题非常小,将allowMissingFiles="true"
置于任务中。这样做的是,如果它找不到build.xml指向的目录中的文件,它仍然允许部署。迁移工具不允许提及package.xml中的组件(如果它们不在目录中,并且使用上述选项的变通方法)。
即使你有一个package.xml来检索一个组织中的所有组件,你只有2个类可以使用deprap,但是相同的包文件可以使用allowmissingfiles = true选项。
答案 4 :(得分:0)
语句但未在压缩目录中找到是与您使用的文件夹名称有关的问题。如果您使用的是自定义文件夹,而不是codepkg或mypkg等,则需要更改 retrieveTarget =“ codepkg” unpackaged =“ codepkg / package.xml” 中的名称,以在您的每个文件夹中反映新名称目标。检查图像转向的链接以获取此说明https://i.stack.imgur.com/GH40d.jpg[1]
答案 5 :(得分:0)
我希望这将对寻求此问题解决方案的人有所帮助。这是一个非常基本的问题,您需要将所有文件放在package.xml所在的同一目录中。例如,如果您要从
部署元数据部署目录/文件夹
除了package.xml之外,其他文件也应属于此文件夹。
部署文件夹将具有以下结构
package.xml
objects
--> Product2.object
--> Account.object
--> Opportunity.object
--> ***
classes
other metadata
当您尝试部署元数据而不将这些文件作为根目录的一部分时,就会出现此问题。