Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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


Published on

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.

Published in: Software
  • Did you try ⇒ ⇐?. They know how to do an amazing essay, research papers or dissertations.
    Are you sure you want to  Yes  No
    Your message goes here

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

  1. 1. #ForceAcademyLA Gear up for Continuous Integration with Salesforce DX, Circle CI and Clayton
  2. 2. #ForceAcademyLA Thank you Sponsors! A Big shout out to our sponsors, without them these events would not be possible:
  3. 3. #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 08474a49 Blog:
  4. 4. #ForceAcademyLA Let’s start CI from scratch!
  5. 5. #ForceAcademyLA ➜What do you need? ➜Why CI? ➜Basic Concepts ➜Design our workflow ➜Run our workflow ➜Add some QA measures ➜Next Steps AGENDA
  6. 6. #ForceAcademyLA Clone my demo repo if you want to work along
  7. 7. #ForceAcademyLA 1. PREREQUISITES
  8. 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)
  9. 9. #ForceAcademyLA 2. WHY CI?
  10. 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. 11. #ForceAcademyLA WHY PUT THE EFFORT IN A CI WORKFLOW Test Automation Deployment Automation Development Lifecycle
  12. 12. #ForceAcademyLA WHY SFDX, Circle CI, Clayton? ➜ SFDX is the new default toolchain to manage Salesforce customizations ➜ Circle CI and integrate seamlessly by SSO with Bitbucket or Github… ➜ the entry tier is free ➜ (relatively) easy to configure
  13. 13. #ForceAcademyLA#ForceAcademyLA Increase Quality More testing less failing deployment
  14. 14. #ForceAcademyLA What do you Need? 3. Prerequisites
  15. 15. #ForceAcademyLA First Steps ➜ Checkout my repo from ➜ Sign up for a CircleCI trial: (single sign-on with Github or Bitbucket) ➜ Sign up for a Clayton.IO trial (single sign-on, again)
  16. 16. #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
  19. 19. #ForceAcademyLA SLEEVES UP! We’re getting our hands dirty
  20. 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: ➜ Easiest (or troubleshooter): ➜ Just read and along in the code, then make a commit into master and check the results
  21. 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:
  22. 22. #ForceAcademyLA 4. Let‘s Build Our Flow
  23. 23. #ForceAcademyLA#ForceAcademyLA Building our flow: STEPS ➜ Clone my repo: ➜ ➜ Sign up and Connect to Circle CI
  24. 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
  25. 25. #ForceAcademyLA#ForceAcademyLA
  26. 26. #ForceAcademyLA#ForceAcademyLA
  27. 27. #ForceAcademyLA#ForceAcademyLA
  28. 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. 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?
  30. 30. #ForceAcademyLA#ForceAcademyLA
  31. 31. #ForceAcademyLA#ForceAcademyLA
  32. 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
  33. 33. #ForceAcademyLA#ForceAcademyLA
  34. 34. #ForceAcademyLA#ForceAcademyLA Bringing it all together – the Workflow Section Use filters and requires to control ➜ order ➜ parallelism ➜ conditions of the workflow execution
  35. 35. #ForceAcademyLA#ForceAcademyLA DONE! ➜ Make a change and commit to your repo… ➜ But don’t push yet…!
  36. 36. #ForceAcademyLA 5. Running our Flow
  37. 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?
  38. 38. #ForceAcademyLA 6. Adding a Quality Gate
  39. 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
  40. 40. #ForceAcademyLA#ForceAcademyLA Quality Gates: STEPS ➜ Sign up for ➜ Connect your repo for a code review ➜ Set up rules
  41. 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
  42. 42. #ForceAcademyLA 7. Next Steps
  43. 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
  44. 44. #ForceAcademyLA#ForceAcademyLA Thank Y u! Any questions? You can find me at: @stangomat Code at