best practices for successful deployment

38
Finish Strong! Jackie Doan Sr. Consultant, Xede Consulting Group, Inc. [email protected] @jackiedoan Best Practices for Successful Deployments Tom Gagne Practice Lead, Xede Consulting Group, Inc. [email protected] @tomgagne

Upload: salesforce-developers

Post on 14-Jan-2017

490 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Best Practices for Successful Deployment

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

Page 2: Best Practices for Successful Deployment

Agenda

Introductions

What’s in a deployment?

Why do deployments fail?

Creating a successful deployment plan

Using programmatic tools for deployment

Q & A

Page 3: Best Practices for Successful Deployment

Jackie DoanSenior Consultant, Xede Consulting Group

@jackiedoan

Page 4: Best Practices for Successful Deployment

Tom GagneEngineering Practice Lead, Xede Consulting Group

@tomgagne

Page 5: Best Practices for Successful Deployment

What’s the number one rule of developing in any software?

Page 6: Best Practices for Successful Deployment

Thou shalt not develop in production!

All changes should be made in a sandbox then deployed - without exception

Page 7: Best Practices for Successful Deployment

What’s in a Deployment?

Page 8: Best Practices for Successful Deployment

Why do deployments fail?

Page 9: Best Practices for Successful Deployment

#DeploymentFish

Page 10: Best Practices for Successful Deployment

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

Page 11: Best Practices for Successful Deployment

Creating a Successful Plan

Page 12: Best Practices for Successful Deployment

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

Page 13: Best Practices for Successful Deployment

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?

Page 14: Best Practices for Successful Deployment

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

Page 15: Best Practices for Successful Deployment

Building a Change Set

Page 16: Best Practices for Successful Deployment

Deployment Plan Deployment Elements - sample

Include the following attributes:

• Object

• Data Type

• Name

• Change Set

• Notes/Manual Steps

Page 17: Best Practices for Successful Deployment

Deployment Plan Step-by-step guide - sample

Page 18: Best Practices for Successful Deployment

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

Page 19: Best Practices for Successful Deployment

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

Page 20: Best Practices for Successful Deployment

Deployment Plan Post-Deployment Steps

What do we need to complete when we’ve finished moving the changes?

• Final manual configuration steps

• Test!

• Communicate

Page 21: Best Practices for Successful Deployment

Command-line tools for Deployment

Page 22: Best Practices for Successful 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

Page 23: Best Practices for Successful Deployment

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

Page 24: Best Practices for Successful Deployment

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

Page 25: Best Practices for Successful Deployment

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

Page 26: Best Practices for Successful Deployment
Page 27: Best Practices for Successful Deployment

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

Page 28: Best Practices for Successful Deployment

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>

Page 29: Best Practices for Successful Deployment

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!

Page 30: Best Practices for Successful Deployment

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.

Page 31: Best Practices for Successful Deployment

Did you know…You can monitor ant deployments from the "Deployment Status" page?

Page 32: Best Practices for Successful Deployment

That last slide was a downer.Let's finish strong!

Page 33: Best Practices for Successful Deployment

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

Page 34: Best Practices for Successful Deployment

Summary

Page 35: Best Practices for Successful Deployment

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

Page 36: Best Practices for Successful Deployment

Questions?

Page 37: Best Practices for Successful Deployment

Thank you

@jackiedoan @tomgagne

Page 38: Best Practices for Successful Deployment

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