简体   繁体   English

Salesforce.com 部署

[英]Salesforce.com deployment

We are currently working on a Salesforce.com custom APEX project that involves a lot of apex classes, triggers and Visualforce pages.我们目前正在处理 Salesforce.com 自定义 APEX 项目,该项目涉及许多顶点类、触发器和 Visualforce 页面。 We also have numerous applications from AppExchange that are part of the system.我们还有许多来自 AppExchange 的应用程序,它们是系统的一部分。

We develop all the Apex Classes, Visualforce pages, etc in test environment and then deploy it to the live environment using Eclipse IDE.我们在测试环境中开发所有 Apex 类、Visualforce 页面等,然后使用 Eclipse IDE 将其部署到实时环境中。 What happens is that every time we deploy changes to the live environment, all the test methods of all the classes (including those from AppExchange Apps) seems to be executing.发生的情况是,每次我们将更改部署到实时环境时,所有类(包括来自 AppExchange Apps 的类)的所有测试方法似乎都在执行。 So deployment of a simple change could end up taking couple of minutes.因此,部署一个简单的更改最终可能需要几分钟。

Is there a way in apex to "package" classes by namespace or something like that so that when we try to deploy a change, only the test methods relevant to that package are executed.在顶点中是否有一种方法可以通过命名空间或类似的东西“打包”类,以便当我们尝试部署更改时,只执行与该包相关的测试方法。 If something like that exists, our deployment can happen much faster.如果存在这样的事情,我们的部署可以更快地进行。

Unfortunately no, there is no partial testing for deployment of apex code, every change, no matter how minute or self-contained triggers a full test run.不幸的是,没有对 apex 代码的部署进行部分测试,每次更改,无论多分钟或多独立都会触发完整的测试运行。 This among other things enforces code metrics (minimum total code coverage for instance)这其中包括强制执行代码指标(例如,最小总代码覆盖率)

IMHO, this is proving to be a two-sided coin when it comes to enforcing code reliability.恕我直言,在强制执行代码可靠性方面,这被证明是一个双面硬币。 When we started using apex all of our tests were very comprehensive performing actual testing of the code with lots of asserts and checks.当我们开始使用 apex 时,我们所有的测试都非常全面,通过大量断言和检查对代码进行了实际测试。 Then we started having very very long deploy times so now our tests serve one and only function, satisfying minimum code coverage, and even with that simplification it takes almost 3 minutes to deploy anything and we only use 20% of our apex code allowance.然后我们开始有非常长的部署时间,所以现在我们的测试服务于一个且唯一的功能,满足最低代码覆盖率,即使有这种简化,部署任何东西也需要近 3 分钟,我们只使用我们的顶点代码限额的 20%。 IMHO2, Apex is way too slow of a coding platform to be enforcing this kind of testing.恕我直言,Apex 的编码平台太慢了,无法执行这种测试。 I cant even imagine how long the tests would run if we reach 50% allowance, not to mention any more.我什至无法想象如果我们达到 50% 的配额,测试会运行多久,更不用说了。

This is possible but you'll need to learn about Apache Ant and have a look at the Force.com Migration Toolkit.这是可能的,但您需要了解 Apache Ant 并查看 Force.com Migration Toolkit。 You can then use a Build file to determine which files are deployed as well as which tests are run.然后,您可以使用构建文件来确定部署了哪些文件以及运行了哪些测试。

I'm busy writing a whitepaper that'll touch on this and other related development strategies... I'll post to my blog when it's done.我正在忙着写一份白皮书,其中会涉及到这个和其他相关的开发策略......完成后我会发布到我的博客上。

If we use the apache ant migration tool we have many options for deployment like deployCodeFailingTest which will skip the test classes and if you want to run only specific test classes please use : something similar to this in ur build.xml如果我们使用 apache ant 迁移工具,我们有许多部署选项,例如 deployCodeFailingTest,它会跳过测试类,如果您只想运行特定的测试类,请使用:在您的 build.xml 中类似的东西

<target name="deployCode">
`<sf:deploy`
username="${sf.username}"
password="${sf.password}"
serverurl="${sf.serverurl}"
deployroot="codepkg">
<runTest>SampleDeployClass</runTest>
</sf:deploy>
</target>

for detailed reference please use this link http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf有关详细参考,请使用此链接http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf

I would recommend the following approach:我会推荐以下方法:

  1. Git as repository for all your sf code Git 作为所有 sf 代码的存储库
  2. jenkins to deploy your code as CI/CD jenkins 将您的代码部署为 CI/CD
  3. PMD as the static code analyser PMD 作为静态代码分析器
  4. sfdx as the deployment method in jenkins for deployment. sfdx 作为 jenkins 中的部署方式进行部署。

Refer the trailhead link: https://trailhead.salesforce.com/users/strailhead/trailmixes/architect-dev-lifecycle-and-deployment请参阅起点链接: https : //trailhead.salesforce.com/users/strailhead/trailmixes/architect-dev-lifecycle-and-deployment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM