#ForceAcademyLA
Gear up for Continuous
Integration
with Salesforce DX,
Circle CI and Clayton
#ForceAcademyLA
Thank you Sponsors!
A Big shout out to our sponsors, without them these events would not
be possible:
#ForceAcademyLA#ForceAcademyLA
Hello!
DANIEL STANGE
Technical Architect
die.interaktiven GmbH & Co. KG
Found Salesforce boring in the dark ages -
Changed my mind.
Frankfurt, Germany User Group Leader
You can find me at:
@stangomat
https://www.linkedin.com/in/daniel-stange-
08474a49
https://trailhead.com/me/stangomat
Blog: blog.danielstange.de
#ForceAcademyLA
Let’s start CI from scratch!
#ForceAcademyLA
➜What do you need?
➜Why CI?
➜Basic Concepts
➜Design our workflow
➜Run our workflow
➜Add some QA measures
➜Next Steps
AGENDA
#ForceAcademyLA
Clone my demo repo if you want to work along
github.com/dstdia/ForceAcademy18
#ForceAcademyLA
1.
PREREQUISITES
#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)
#ForceAcademyLA
2.
WHY CI?
#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
#ForceAcademyLA
WHY PUT THE EFFORT IN A CI WORKFLOW
Test
Automation
Deployment
Automation
Development
Lifecycle
#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
#ForceAcademyLA#ForceAcademyLA
Increase
Quality
More testing
less failing deployment
#ForceAcademyLA
What do you
Need?
3.
Prerequisites
#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)
#ForceAcademyLA
ORCHESTRATION
sfdx force:org:create
sfdx force:source:push
sfdx force:apex:test:run
sfdx force:source:convert
sfdx force:mdapi:deploy
➜ Create an org
➜ Install your
source
➜ Run tests
➜ Convert to
Metadata
format
➜ Deploy to
target
#ForceAcademyLA
CI ORCHESTRATION
WORKFLOW
JOB(S)
STEPS
#ForceAcademyLA
CI ORCHESTRATION
WORKFLOW
JOB(S)
STEPS
STEPS
JOB(S)
STEPS
STEPS
#ForceAcademyLA
SLEEVES UP!
We’re getting our hands dirty
#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
#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
#ForceAcademyLA
4.
Let‘s Build
Our Flow
#ForceAcademyLA#ForceAcademyLA
Building our flow: STEPS
➜ Clone my repo:
➜ https://github.com/dstdia/ForceAcademy18
➜ Sign up and Connect to Circle CI
#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
#ForceAcademyLA#ForceAcademyLA
#ForceAcademyLA#ForceAcademyLA
#ForceAcademyLA#ForceAcademyLA
#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
#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?
#ForceAcademyLA#ForceAcademyLA
#ForceAcademyLA#ForceAcademyLA
#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
#ForceAcademyLA#ForceAcademyLA
#ForceAcademyLA#ForceAcademyLA
Bringing it all together – the Workflow Section
Use filters and
requires to control
➜ order
➜ parallelism
➜ conditions
of the workflow
execution
#ForceAcademyLA#ForceAcademyLA
DONE!
➜ Make a change and commit to your repo…
➜ But don’t push yet…!
#ForceAcademyLA
5.
Running our Flow
#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?
#ForceAcademyLA
6.
Adding a
Quality Gate
#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
#ForceAcademyLA#ForceAcademyLA
Quality Gates: STEPS
➜ Sign up for Clayton.io
➜ Connect your repo for a code review
➜ Set up rules
#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
#ForceAcademyLA
7.
Next Steps
#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
#ForceAcademyLA#ForceAcademyLA
Thank Y u!
Any questions?
You can find me at:
@stangomat
Daniel.stange@die-interaktiven.de
Code at github.com/dstdia/ForceAcademy18

Gear up for Continuous Integration with Salesforce DX, Circle CI and Clayton