Everyone in the Salesforce ecosystem knows how painful the rollout of changes with Changeset can be, and how tedious the setup for Ant build jobs is. Luckily, Salesforce DX is a huge leap forward in terms of modern enterprise software lifecycle management. I am going to present how my development toolchain links DX, Clayton and Circle CI, and we are going to build a Circle configuration together to help you getting rid of change sets forever.
8. #ForceAcademyLA
PREREQUISITES * What do you need to start?
➜ Salesforce DX Developer Hub
(your Prod or a trial dev hub org)
➜ A distributed version control system.
Github or Bitbucket are great
➜ The Salesforce CLI (part of Salesforce DX)
10. #ForceAcademyLA
WHY CI?
Extra effort to save some time and effort?
➜ Structured Change Process:
Repeatable, automated, transparent
➜ Find bugs and flaws
➜ Deploy more often and earlier
➜ Reduce the effort to collect and deploy changes
➜ Reduce deployment failures
➜ Promote agile / iterative approach
➜ Introduce QA steps
11. #ForceAcademyLA
WHY PUT THE EFFORT IN A CI WORKFLOW
Test
Automation
Deployment
Automation
Development
Lifecycle
12. #ForceAcademyLA
WHY SFDX, Circle CI, Clayton?
➜ SFDX is the new default toolchain to manage
Salesforce customizations
➜ Circle CI and Clayton.io integrate seamlessly by
SSO with Bitbucket or Github…
➜ the entry tier is free
➜ (relatively) easy to configure
15. #ForceAcademyLA
First Steps
➜ Checkout my repo from
http://bit.ly/DSTFA18-Code
➜ Sign up for a CircleCI trial:
https://circleci.com/
(single sign-on with Github or Bitbucket)
➜ Sign up for a Clayton.IO trial
https://getclayton.io
(single sign-on, again)
20. #ForceAcademyLA#ForceAcademyLA
HANDS ON – Choose your path
➜ Advanced Path:
Work along while I demo
➜ Easier Path:
Use the Cheatsheets in my repo’s wiki to
copy&paste:
http://bit.ly/DSTFA18-Wiki
➜ Easiest (or troubleshooter):
➜ Just read and along in the code, then make a
commit into master and check the results
21. #ForceAcademyLA#ForceAcademyLA
HANDS ON – What you will need
➜ A self signed certificate and a connected app in
your dev hub and all deploy targets
➜ Read how to do it here: http://bit.ly/SFDXCert
24. #ForceAcademyLA#ForceAcademyLA
Building our flow: The DX setup job
➜ Understand the Structure of the Jobs-Section
➜ Download and install Salesforce DX
➜ Authenticate your Org
➜ Create and Persist a Workspace
28. #ForceAcademyLA#ForceAcademyLA
Remember…
➜ Jobs run in independent containers. You have to
persist what you want to use later…
➜ You’ll have to export paths to your containers later
➜ You can use caches and folders to store artefacts
29. #ForceAcademyLA#ForceAcademyLA
Building our flow: The Test Execution job
➜ Create a new scratch org
➜ Checkout source
➜ Push Source to test org
➜ Execute the Apex Unit Tests
➜ Persist the Results
➜ Can you add Lightning Testing Service on your own?
32. #ForceAcademyLA#ForceAcademyLA
Building our flow: The Deployment job
Typically you will need a Sandbox or Production Org to
deploy to.
We can use a scratch org here. Feel free to use an
existing DE or Sandbox instead.
➜ Convert Source to Metadata API format
➜ Deploy Metadata
37. #ForceAcademyLA#ForceAcademyLA
Running our flow: STEPS
o Now push your commit to origin
o Extra: Make any other change you like.
o Review your CircleCI workflow – did it complete?
Can you fix the error if you get any?
39. #ForceAcademyLA
Using static code analysis as Quality Gate
➜ Static code analysis checks your code/metadata
against pre -defined rules
➜ Clayton is Salesforce specific, engine is built to
“understand” the context of your code
➜ Clayton ”talks” to your CVS
➜ Violations appear as errors and can be used to
block merges
➜ Can be used in addition to or instead of local
static code analysis like PMD / ApexPMD
41. #ForceAcademyLA#ForceAcademyLA
Quality Gates: TRY IT OUT
➜ Modify the Sample Class to violate your Clayton rule
set
➜ add DML in a loop
➜ Or an empty method
➜ Or a badly named method (like
Badly_namedMethod() )
➜ Commit & push
➜ Check the Clayton results
➜ Review your commit in Github / Bitbucket
43. #ForceAcademyLA#ForceAcademyLA
NEXT STEPS
➜ Break down monolythic metadata
➜ use 2nd generation packages to have smaller
installable bundles
➜ Parallelize jobs to save time
➜ Handle test results and failures