best practices for successful deployment
TRANSCRIPT
Finish Strong!
Jackie DoanSr. Consultant, Xede Consulting Group, [email protected]@jackiedoan
Best Practices for Successful Deployments
Tom GagnePractice Lead, Xede Consulting Group, [email protected]@tomgagne
Agenda
Introductions
What’s in a deployment?
Why do deployments fail?
Creating a successful deployment plan
Using programmatic tools for deployment
Q & A
Jackie DoanSenior Consultant, Xede Consulting Group
@jackiedoan
Tom GagneEngineering Practice Lead, Xede Consulting Group
@tomgagne
What’s the number one rule of developing in any software?
Thou shalt not develop in production!
All changes should be made in a sandbox then deployed - without exception
What’s in a Deployment?
Why do deployments fail?
#DeploymentFish
Why do Deployments Fail?
There are several different types of failures:• Failure to Deploy:
• Missing elements
• Unit Test Failures (Apex Test Classes)
• Code Coverage < 75%
• Validation rules
• Insufficient Security to deploy
• Post-Deployment Failures
• SECURITY isn’t set properly for users
• Data was improperly loaded
• Old stuff no longer works – no regression testing
• Failure due to poor user training/communication
Creating a Successful Plan
Deployment Plan Overview
Why do we need a plan?
• We are far more forgetful than we realize!
• Dependencies can wreak havoc with a deployment
• A comprehensive plan ensures that everyone knows what is happening, and when
• Keeps everyone accountable
Strategy
How do we come up with a plan?
Ask yourself some questions:• Who will be deploying?
• What tools?
• When?
• Do we need to load any data?
• Who will test post-deployment?
• What’s the communication plan?
• What’s our roll-back plan?
Building the Plan
What needs to be in a plan?• Most obvious – deployment elements
• Objects, fields, Page Layouts, Record Types, Processes, Flows
• Don’t forget the less obvious elements!
• Should I include profiles?
• Step-by-step guide
Building a Change Set
•
Deployment Plan Deployment Elements - sample
Include the following attributes:
• Object
• Data Type
• Name
• Change Set
• Notes/Manual Steps
Deployment Plan Step-by-step guide - sample
Deployment Plan Pre-Deployment Steps
What do we need to consider before we start deployment?
• Build your change set
• Make sure you have the right data
• Ensure that your plan for communication is clear and effective
Deployment Plan Deployment Steps
If you’ve created an effective plan, this should be the easiest part!
• Deploy your change set(s)
• Manual changes/configurations that need to be made between change sets
• Load your data
Deployment Plan Post-Deployment Steps
What do we need to complete when we’ve finished moving the changes?
• Final manual configuration steps
• Test!
• Communicate
Command-line tools for Deployment
Benefits of Ant, Migration Tool, IDEs, and Scripts
● Org relationships not required○ Can deploy without an org○ Great for bootstrapping
● Easy to automate● Easy to extend● Can both push and pull
Example of Automation and Extending : Xede's "build"
● Hides "ant" syntax● Hides "ant" output● Easy to remember● Supports "globbing"● Emails script output● Included in all our
repo directories (over 200!)
DrozBook> build
usage:build username login|test [glob]
if glob is included, a directory will
deploy
build -- deploy using standard settings
tbuild -- deploy and run unit tests
unbuild -- removes items from an org
vbuild -- validate without deploying
xbuild -- extracts from salesforce using
package.xml
DrozBook:xede-sf-vics tgagne$ build [email protected] login Password:
Feedback:
Email to:
Username: [email protected]
ServerURL: https://login.salesforce.com
CHECKONLY=false
RUNALLTESTS=false
ant deployDir
Buildfile: /Users/tgagne/git/xede-sf-vics/build.xml
deployDir:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af3700000C4VUcCAN
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy] Request Status: Succeeded
[sf:deploy] *********** DEPLOYMENT SUCCEEDED ***********
[sf:deploy] Finished request 0Af3700000C4VUcCAN successfully.
BUILD SUCCESSFUL
Total time: 13 seconds
Change destinations just by changing the username
Use wild cards (globbing) to select what to send
Email the output to let others know what you did
DrozBook:xede-sf-vics tgagne$ build [email protected] login classes/Vics.cls* Password:
Feedback:
Email to: [email protected]
Username: [email protected]
ServerURL: https://login.salesforce.com
Archive: /tmp/build.8088/deploy.zip
Length Date Time Name
-------- ---- ---- ----
564 03-18-14 14:50 package.xml
5776 09-12-13 00:16 classes/Vics.cls
174 09-12-13 00:16 classes/Vics.cls-meta.xml
-------- -------
6514 3 files
Buildfile: /Users/tgagne/git/xede-sf-vics/build.xml
deployZip:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af3700000C4VV1CAN
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress (0/1) -- Processing Type: ApexClass
[sf:deploy] Request Status: Succeeded
[sf:deploy] *********** DEPLOYMENT SUCCEEDED ***********
[sf:deploy] Finished request 0Af3700000C4VV1CAN successfully.
BUILD SUCCESSFUL
Total time: 12 seconds
Send email to [email protected]? y
Cleaning-up after yourself - destructiveChanges.xml
● Deployments and change sets change/add - no delete● Remove orphaned or abandoned objects, fields● Remove development-only artifacts
○ Test classes, pages, components● Clean-up after your customers and users
○ Great for deleting reports
Cleaning-up after yourself
destructiveChanges.xml
● Has the same format as package.xml
● Use to remove obsolete metadata including custom fields
● Copy your package.xml to remove everything
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Vics</members>
<members>VicsTest</members>
<name>ApexClass</name>
</types>
<types>
<members>Activity.Event_UID__c</members>
<name>CustomField</name>
</types>
<types>
<members>Vics</members>
<name>RemoteSiteSetting</name>
</types>
<types>
<members>VicsTestData</members>
<name>StaticResource</name>
</types>
<version>29.0</version>
</Package>
DrozBook:xede-sf-vics tgagne$ unbuild [email protected] login
Password:
Feedback:
Email to:
Username: [email protected]
ServerURL: https://login.salesforce.com
Buildfile: /Users/tgagne/git/xede-sf-vics/build.xml
undeployCode:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af3700000C4VVLCA3
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy] Request Status: Succeeded
[sf:deploy] *********** DEPLOYMENT SUCCEEDED ***********
[sf:deploy] Finished request 0Af3700000C4VVLCA3 successfully.
BUILD SUCCESSFUL
Total time: 12 seconds
Let's undo everything we did!
DrozBook:xede-sf-vics tgagne$ unbuild [email protected] login
Username: [email protected]
ServerURL: https://login.salesforce.com
undeployCode:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af3700000C4Zk0CAF
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy]
-----------------------------------------------------------------------------------
[sf:deploy] Component Failures:
[sf:deploy] 1. destructiveChanges.xml -- Warning: No RemoteSiteSetting named: Vics found
[sf:deploy]
-----------------------------------------------------------------------------------
[sf:deploy] Request Status: Failed
BUILD FAILED
/Users/tgagne/git/xede-sf-vics/build.xml:38:
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af3700000C4Zk0CAF
All Component Failures:
1. destructiveChanges.xml -- Warning: No RemoteSiteSetting named: Vics found
2. destructiveChanges.xml -- Warning: No ApexClass named: Vics found
3. destructiveChanges.xml -- Warning: No CustomField named: Activity.Event_UID__c found
4. destructiveChanges.xml -- Warning: No StaticResource named: VicsTestData found
5. destructiveChanges.xml -- Warning: No ApexClass named: VicsTest found
*********** DEPLOYMENT FAILED ***********
Total time: 11 seconds
Let's make sure we undid everything we did.
Did you know…You can monitor ant deployments from the "Deployment Status" page?
That last slide was a downer.Let's finish strong!
Resources
Force.com Migration Tool Overviewhttps://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/
Build Scriptshttps://bitbucket.org/xcgi/xede-linux-build
SF Template (fork for your own)https://bitbucket.org/xcgi/xede-sf-template
List of metadata types for package.xml and destructiveChanges.xmlhttps://developer.salesforce.com/docs/atlas.en-us.196.0.api_meta.meta/api_meta/meta_types_list.htm
Summary
Summary
Deployments are a way to move elements - config and code - between development environments and production
‘Planning’ makes perfect
• Never develop in production!
• Deployment plans can make large, complex deployments go off without a hitch
Command line tools let you...
• Automate
• Easily rinse/repeat
• Extend/Customize
• Destructive Changes--cleaning up after yourself and your customer/users
Questions?
Thank you
@jackiedoan @tomgagne
Share Your Feedback, and Win a GoPro!
3 Earn a GoPro prize entry for each completed surveyTap the bell to take a survey2Enroll in a session1