SlideShare a Scribd company logo
CI - SFDX + Bitbucket Pipelines
Secure, Simplified and Economical CI
Sat śrī akāl & Namaste
● Abhinav Gupta
● Salesforce MVP (8x) & Architect
● CEO & Founder of concret.io (Salesforce PDO
& ISV Partner)
● I can still code very well, and quite passionate
about it.
● Started with Java in 2004, Salesforce journey
started in 2008.
twitter : @abhinavguptas
Agenda
● What is CI ?
● Why CI?
● Blockers
● Various CI Tools
● Cost Comparison
● Deep Dive into Bitbucket Pipelines
● Bitbucket Tips
CI - “Ki Raula Payea Ehna”?
Why so much noise about it?
Continuous Integration (CI)
● Best Practice
● Central Repo for code/metadata is only “source of truth”.
● All code from each developer resides in that repo.
● Automated Builds to ensure early discovery of bugs/issues.
Still Why - Continuous Integration (CI) ?
It’s easy
● To break one thing while fixing others.
● To ignore minor dependencies between components.
● To ship the same (in absence of QA, or release pressure).
Imagine this with multi developers, and modules in medium/large
scale projects.
What’s biggest blocker?
In getting successful with CI.
I don’t know CI, GIT etc.
I don’t care about this.
Quality of Automated Tests
Bad Test Case Example
Just for sake of code coverage.
With no assertions of
attributes being correctly
populated in the result.
! Big CI failure !
Even best CI tool can’t help with such quality of test
cases.
● Check intentions to write good quality test cases
● Create positive and negative scenarios
● Try following TDD (Test Driven Development) - OPTIONAL
● We all know Apex could be tested via unit tests.
● Aura and LWC can also be unit tested via Jest, Jasmine, Mocha etc. - OPTIONAL
Good news - Not just Apex, but Aura/LWC unit tests can be auto executed in CI env.
CI Prerequisites for Salesforce
Various CI Tools
External Tools
● Are not part of your repo / git hosting service.
● Setup private/internal hosting, or configure
hosted solution subscriptions.
● Offer limited free build minutes /
concurrency.
● Examples:
○ Jenkins
○ CircleCI
○ TravisCI
Internal Tools
● Offered as part of your repo / git hosting
service.
● No need to setup extra server or hosting.
● No new subscription $$ (most of the times).
● Examples:
○ Bitbucket Pipelines
○ GitLab Pipelines
Quick Cost Comparison
As per pricing details listed 20th July 2019
External CI Tools - Circle CI Costing
https://circleci.com/pricing/
External CI Tools - Travis CI Costing
https://travis-ci.com/plans
Internal CI Tools - Bitbucket Costing
https://bitbucket.org/product/pricing
Internal CI Tools - GitLab Costing
https://about.gitlab.com/pricing/
My preference
Internal CI Tools is my preference for many reason like
- No more extra CI server to configure and worry about.
- No extra subscription to buy and manage.
- No app switching.
- Code / IP is not exposed to external servers, which could be insecure. Specially, CI
tool configured on a poorly secured internal servers.
- Over exposure to all GIT projects, which one might not want to expose to CI.
- One just needs to commit a XML config file for enabling CI.
- Git repo auto starts Docker image, and runs the script.
- CI results, permissions are well integrated in the repo only.
Bottom Line: Pipelines and internal CI tools are very good for small projects, with quick
build times and not huge Processing/RAM requirements.
Deep Dive Bitbucket Pipelines
Exploring some key areas, and how tos.
CI - Skills Checklist
● SFDX
○ One can use ANT migration tool, but SFDX with scratch orgs etc makes it very easy and quick.
● GIT (VCS)
○ Clients like “Source Tree” and many others don’t require a geek level command line expertise.
○ Having basic idea of commits, pull, push, branching and pull requests is good starting point.
● Scripting / Shell
○ Not really, Salesforce team gave a very good script which is good and doesn’t needs editing.
○ Basic scripting is not that hard.
● Discipline / Process
○ A well defined process to use feature and bug branches, and code reviews before the solution is
merged back into master, possibly via QA > UAT branches.
○ It’s not must, but helps a lot
● Attitude
○ Towards writing good tests, and investing some time in grooming these skills.
Typical CI Flow
Simple CI for starting up
● Code/metadata pushed to a target branch.
● CI System/Bitbucket executes the CI Scripting file, which typically
○ Create new scratch org.
○ Push all the code/metadata to new scratch org.
○ Run tests
○ Deletes the same scratch org.
○ It Optionally
■ Create new package version, attempt install of the package in new scratch org
■ Run tests to ensure stability of the same
Setting up Bitbucket Pipelines for Salesforce (via SFDX)
https://github.com/forcedotcom/sfdx-bitbucket-package
^ Above open source repo from Salesforce is well documented example.
It clearly shows:
● How to setup connected apps.
● Using JWT grants via SFDX for automated/headless authentication.
● A complete bitbucket-pipelines.yml file, which covers all the steps mentioned in the
previous slide.
It shouldn’t take more than 15-20 mins to configure all of the steps mentioned in the
README.
Careful - About Scratch Org Limits
Edition Active Scratch
Org Allocation
Daily Scratch
Org Allocation
Developer Edition or trial 3 6
Enterprise Edition 40 80
Unlimited Edition 100 200
Performance Edition 100 200
● It’s quite easy to get super excited about CI
and scratch orgs.
● Before planning a CI flow of your fantasy,
please check the table on the right >
● If your customer/partner is not having
enterprise edition org, you need to check
○ Number of developers in team.
○ Frequency of spinning new scratch orgs
in team for hotfixes, bugs and features.
○ CI enabled branches, where auto
scratch org creation will happen, and
what is the frequency.
Purposeful & Sensible CI
● We saw limits on number of scratch orgs one can spin on daily basis.
● It’s quite easy to overdo CI, if applied to all branches.
● Imagine, scratch orgs getting created on commit in any branch.
● It might not be helpful and easily burnup the scratch org limits.
● Add unit testing code in key release branches, like TEST, QA, UAT. Avoid it in hotfix, feature etc.
Purposeful & Sensible CI
Sample script showing feature branches ignored for Auto test runs, and scratch org creation.
pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
branches:
master:
- step:
script:
- sfdx force:org:create --targetdevhubusername HubOrg --setdefaultusername --definitionfile config/project-scratch-def.json --
setalias ciorg --wait 10 --durationdays 1
- sfdx force:org:display --targetusername ciorg
#Push source to scratch org
- sfdx force:source:push --targetusername ciorg
#Run unit tests on scratch org
- sfdx force:apex:test:run --targetusername ciorg --wait 10 --resultformat tap --codecoverage --testlevel $TESTLEVEL
#Delete scratch org
- sfdx force:org:delete --targetusername ciorg --noprompt
feature/*:
- step:
script:
- echo "Avoid anything scratch org stuff on feature/* pattern."
Some Bitbucket Tips
Branch Permissions
- Keep feature and other dev
branches open for all.
- Lock WRITE access to sensitive and
final branches like UAT/Prod to a
few responsible engineers.
- They should code review and make
sure no junk is coming in.
- It’s good to document and agree on
a branching model in the team.
- Bitbucket helps with that, by clearly
defining feature, hotfix, bugfix and
release branches.
Branching Model
- How nice it will be to auto assign reviewers on pull requests. (pic below)
Default Reviewers
- REPO variables are used in CI scripting to access various normal and
sensitive data. Bitbucket allows easy masking of sensitive information. Just
check the “Secured” option when adding the variables.
Safe Repo Variables
More control on security
“Deployments” feature allows one to
- Tag env as Test, Staging and Prod
- Have clear separation of env
variables for each of them. Which
are only editable by configured
admins.
- Fine permission control on which
branches, people can deploy to that
env.
Integrations
Allows Bitbucket to talk to your Bug
Tracking or Build System.
This option gives you ready made scripts
to integrate with your Bug tracking or
build tracking system.
Mostly requires copying some API keys
etc and setting up the env. Variable.
Slack / Chat Alerts
It’s no code, a simple OAuth with Slack
will take it forward >
Salesforce example uses
Docker based pipelines
config file. If your
organisation works on
Java, Python and other
language, variety of
sample pipeline config
files are available, which
work easily on gradle,
maven etc.
Multi Language Templates
Thanks
Q & A
● Official Salesforce Repo for Bitbucket Pipelines
○ https://github.com/forcedotcom/sfdx-bitbucket-package
● Continuous Integration with Salesforce DX
○ https://developer.salesforce.com/blogs/2019/05/continuous-integration-with-salesforce-dx.html
● Trailhead
○ https://trailhead.salesforce.com/en/content/learn/modules/sfdx_travis_ci
○ https://trailhead.salesforce.com/en/content/learn/modules/heroku-flow/learn-about-continuous-integration-deployment-
and-delivery
References

More Related Content

PPTX
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
PPTX
Full Page Writes in PostgreSQL PGCONFEU 2022
PDF
Alfresco Security Best Practices Guide
PDF
Introduction to eBPF
PPTX
Jenkins CI
PDF
Multi Chassis LAG for Cloud builders
PPTX
Salesforce: CI,CD & CT
PDF
ARMアーキテクチャにおけるセキュリティ機構の紹介
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Full Page Writes in PostgreSQL PGCONFEU 2022
Alfresco Security Best Practices Guide
Introduction to eBPF
Jenkins CI
Multi Chassis LAG for Cloud builders
Salesforce: CI,CD & CT
ARMアーキテクチャにおけるセキュリティ機構の紹介

What's hot (20)

PPTX
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
PDF
Microservices Workshop - Craft Conference
PDF
[PYCON Korea 2018] Python Application Server for Recommender System
PDF
Docker道場オンライン#1 Docker基礎概念と用語の理解
PPTX
Container Orchestration
PDF
Kubernetes - A Comprehensive Overview
PDF
RS485(Modbus) -LoRaWANコンバーター RS485-LN 日本語マニュアル
PPTX
Docker: From Zero to Hero
PDF
VictoriaLogs: Open Source Log Management System - Preview
PDF
Git Branching Model
PPT
Docker introduction
PPTX
Artifacts management with DevOps
PDF
Dockerイメージの理解とコンテナのライフサイクル
PDF
Git training v10
PDF
PPTX
Version control system
PPTX
Bare Metal Cluster with Kubernetes, Istio and Metallb | Nguyen Phuong An, Ngu...
PDF
Gain Better Observability with OpenTelemetry and InfluxDB
PDF
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
PDF
仮想化環境におけるパケットフォワーディング
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Microservices Workshop - Craft Conference
[PYCON Korea 2018] Python Application Server for Recommender System
Docker道場オンライン#1 Docker基礎概念と用語の理解
Container Orchestration
Kubernetes - A Comprehensive Overview
RS485(Modbus) -LoRaWANコンバーター RS485-LN 日本語マニュアル
Docker: From Zero to Hero
VictoriaLogs: Open Source Log Management System - Preview
Git Branching Model
Docker introduction
Artifacts management with DevOps
Dockerイメージの理解とコンテナのライフサイクル
Git training v10
Version control system
Bare Metal Cluster with Kubernetes, Istio and Metallb | Nguyen Phuong An, Ngu...
Gain Better Observability with OpenTelemetry and InfluxDB
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
仮想化環境におけるパケットフォワーディング
Ad

Similar to Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines (20)

PDF
TDX19 - Accelerate DevOps with GitLab and Salesforce
PPTX
How Open Source Embiggens Salesforce.com
PPTX
Automating Deployment Between Orgs Using Git & Continuous Integration
PDF
Portable CI wGitLab and Github led by Gavin Pickin.pdf
PDF
Getting to Walk with DevOps
PDF
Salesforce cicd integration a quick guide
PDF
Bitbucket Pipelines
PDF
Promise of DevOps
PPTX
Setting Up CircleCI Workflows for Your Salesforce Apps
PPTX
Salesforce CI pipelines demystified, Mariia Pyvovarchuk
PDF
Accenture Salesforce Developer Meetup vol 1 2019
PDF
DevOps and SF.pdf
PPTX
DevOps in Salesforce AppCloud
PDF
Open Source at Salesforce.com
PDF
Reusable Build Scripts for Managed Package Development (October 14, 2014)
PDF
CI-solutions-Versus-AutoRABIT
PDF
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
PPTX
Investing in a good software factory and automating the build process
PPTX
Best practices for implementing CI/CD on Salesforce
PPTX
Git/Github & Salesforce
TDX19 - Accelerate DevOps with GitLab and Salesforce
How Open Source Embiggens Salesforce.com
Automating Deployment Between Orgs Using Git & Continuous Integration
Portable CI wGitLab and Github led by Gavin Pickin.pdf
Getting to Walk with DevOps
Salesforce cicd integration a quick guide
Bitbucket Pipelines
Promise of DevOps
Setting Up CircleCI Workflows for Your Salesforce Apps
Salesforce CI pipelines demystified, Mariia Pyvovarchuk
Accenture Salesforce Developer Meetup vol 1 2019
DevOps and SF.pdf
DevOps in Salesforce AppCloud
Open Source at Salesforce.com
Reusable Build Scripts for Managed Package Development (October 14, 2014)
CI-solutions-Versus-AutoRABIT
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
Investing in a good software factory and automating the build process
Best practices for implementing CI/CD on Salesforce
Git/Github & Salesforce
Ad

More from Abhinav Gupta (20)

PDF
What is Einstein Data Detect?
PDF
Salesforce 2023 Recap
PDF
Safeguarding Salesforce: Mastering Data Security with Data Mask
PDF
🤖 Understanding 4 Waves of AI
PDF
AI & Evolving Customer Trust Dynamics (1).pdf
PDF
Salesforce Functions History - Launch to Retirement (2019-2023)
PDF
Unlocking the Puzzle of Modern Customer Wants.pdf
PDF
NFT Collectors - Understanding AI Puke Art
PDF
What’s Web3 for Salesforce?
PDF
Generative AI Art - The Dark Side
PDF
Whats, Whys and Hows of NFTs?
PDF
Mental Peace at Work during Pandemic
PDF
Salesforce restriction rules <2 min Summary
PDF
Building a layoff proof career
PDF
Fun with Jenkins & Salesforce
PPTX
Dreamforce 2015 Session - Angular-ifying your visualforce pages
PPTX
Intro to Apex - Salesforce Force Friday Webinar
PPTX
Building Chrome Extensions For Salesforce
PPTX
Learning salesforce-mobile-way
PPTX
Parsing XML & JSON in Apex
What is Einstein Data Detect?
Salesforce 2023 Recap
Safeguarding Salesforce: Mastering Data Security with Data Mask
🤖 Understanding 4 Waves of AI
AI & Evolving Customer Trust Dynamics (1).pdf
Salesforce Functions History - Launch to Retirement (2019-2023)
Unlocking the Puzzle of Modern Customer Wants.pdf
NFT Collectors - Understanding AI Puke Art
What’s Web3 for Salesforce?
Generative AI Art - The Dark Side
Whats, Whys and Hows of NFTs?
Mental Peace at Work during Pandemic
Salesforce restriction rules <2 min Summary
Building a layoff proof career
Fun with Jenkins & Salesforce
Dreamforce 2015 Session - Angular-ifying your visualforce pages
Intro to Apex - Salesforce Force Friday Webinar
Building Chrome Extensions For Salesforce
Learning salesforce-mobile-way
Parsing XML & JSON in Apex

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Encapsulation theory and applications.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Understanding_Digital_Forensics_Presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Review of recent advances in non-invasive hemoglobin estimation
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation theory and applications.pdf
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
CIFDAQ's Market Insight: SEC Turns Pro Crypto

Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines

  • 1. CI - SFDX + Bitbucket Pipelines Secure, Simplified and Economical CI
  • 2. Sat śrī akāl & Namaste ● Abhinav Gupta ● Salesforce MVP (8x) & Architect ● CEO & Founder of concret.io (Salesforce PDO & ISV Partner) ● I can still code very well, and quite passionate about it. ● Started with Java in 2004, Salesforce journey started in 2008. twitter : @abhinavguptas
  • 3. Agenda ● What is CI ? ● Why CI? ● Blockers ● Various CI Tools ● Cost Comparison ● Deep Dive into Bitbucket Pipelines ● Bitbucket Tips
  • 4. CI - “Ki Raula Payea Ehna”? Why so much noise about it?
  • 5. Continuous Integration (CI) ● Best Practice ● Central Repo for code/metadata is only “source of truth”. ● All code from each developer resides in that repo. ● Automated Builds to ensure early discovery of bugs/issues.
  • 6. Still Why - Continuous Integration (CI) ? It’s easy ● To break one thing while fixing others. ● To ignore minor dependencies between components. ● To ship the same (in absence of QA, or release pressure). Imagine this with multi developers, and modules in medium/large scale projects.
  • 7. What’s biggest blocker? In getting successful with CI.
  • 8. I don’t know CI, GIT etc.
  • 9. I don’t care about this.
  • 11. Bad Test Case Example Just for sake of code coverage. With no assertions of attributes being correctly populated in the result.
  • 12. ! Big CI failure ! Even best CI tool can’t help with such quality of test cases.
  • 13. ● Check intentions to write good quality test cases ● Create positive and negative scenarios ● Try following TDD (Test Driven Development) - OPTIONAL ● We all know Apex could be tested via unit tests. ● Aura and LWC can also be unit tested via Jest, Jasmine, Mocha etc. - OPTIONAL Good news - Not just Apex, but Aura/LWC unit tests can be auto executed in CI env. CI Prerequisites for Salesforce
  • 14. Various CI Tools External Tools ● Are not part of your repo / git hosting service. ● Setup private/internal hosting, or configure hosted solution subscriptions. ● Offer limited free build minutes / concurrency. ● Examples: ○ Jenkins ○ CircleCI ○ TravisCI Internal Tools ● Offered as part of your repo / git hosting service. ● No need to setup extra server or hosting. ● No new subscription $$ (most of the times). ● Examples: ○ Bitbucket Pipelines ○ GitLab Pipelines
  • 15. Quick Cost Comparison As per pricing details listed 20th July 2019
  • 16. External CI Tools - Circle CI Costing https://circleci.com/pricing/
  • 17. External CI Tools - Travis CI Costing https://travis-ci.com/plans
  • 18. Internal CI Tools - Bitbucket Costing https://bitbucket.org/product/pricing
  • 19. Internal CI Tools - GitLab Costing https://about.gitlab.com/pricing/
  • 20. My preference Internal CI Tools is my preference for many reason like - No more extra CI server to configure and worry about. - No extra subscription to buy and manage. - No app switching. - Code / IP is not exposed to external servers, which could be insecure. Specially, CI tool configured on a poorly secured internal servers. - Over exposure to all GIT projects, which one might not want to expose to CI. - One just needs to commit a XML config file for enabling CI. - Git repo auto starts Docker image, and runs the script. - CI results, permissions are well integrated in the repo only. Bottom Line: Pipelines and internal CI tools are very good for small projects, with quick build times and not huge Processing/RAM requirements.
  • 21. Deep Dive Bitbucket Pipelines Exploring some key areas, and how tos.
  • 22. CI - Skills Checklist ● SFDX ○ One can use ANT migration tool, but SFDX with scratch orgs etc makes it very easy and quick. ● GIT (VCS) ○ Clients like “Source Tree” and many others don’t require a geek level command line expertise. ○ Having basic idea of commits, pull, push, branching and pull requests is good starting point. ● Scripting / Shell ○ Not really, Salesforce team gave a very good script which is good and doesn’t needs editing. ○ Basic scripting is not that hard. ● Discipline / Process ○ A well defined process to use feature and bug branches, and code reviews before the solution is merged back into master, possibly via QA > UAT branches. ○ It’s not must, but helps a lot ● Attitude ○ Towards writing good tests, and investing some time in grooming these skills.
  • 23. Typical CI Flow Simple CI for starting up ● Code/metadata pushed to a target branch. ● CI System/Bitbucket executes the CI Scripting file, which typically ○ Create new scratch org. ○ Push all the code/metadata to new scratch org. ○ Run tests ○ Deletes the same scratch org. ○ It Optionally ■ Create new package version, attempt install of the package in new scratch org ■ Run tests to ensure stability of the same
  • 24. Setting up Bitbucket Pipelines for Salesforce (via SFDX) https://github.com/forcedotcom/sfdx-bitbucket-package ^ Above open source repo from Salesforce is well documented example. It clearly shows: ● How to setup connected apps. ● Using JWT grants via SFDX for automated/headless authentication. ● A complete bitbucket-pipelines.yml file, which covers all the steps mentioned in the previous slide. It shouldn’t take more than 15-20 mins to configure all of the steps mentioned in the README.
  • 25. Careful - About Scratch Org Limits Edition Active Scratch Org Allocation Daily Scratch Org Allocation Developer Edition or trial 3 6 Enterprise Edition 40 80 Unlimited Edition 100 200 Performance Edition 100 200 ● It’s quite easy to get super excited about CI and scratch orgs. ● Before planning a CI flow of your fantasy, please check the table on the right > ● If your customer/partner is not having enterprise edition org, you need to check ○ Number of developers in team. ○ Frequency of spinning new scratch orgs in team for hotfixes, bugs and features. ○ CI enabled branches, where auto scratch org creation will happen, and what is the frequency.
  • 26. Purposeful & Sensible CI ● We saw limits on number of scratch orgs one can spin on daily basis. ● It’s quite easy to overdo CI, if applied to all branches. ● Imagine, scratch orgs getting created on commit in any branch. ● It might not be helpful and easily burnup the scratch org limits. ● Add unit testing code in key release branches, like TEST, QA, UAT. Avoid it in hotfix, feature etc.
  • 27. Purposeful & Sensible CI Sample script showing feature branches ignored for Auto test runs, and scratch org creation. pipelines: default: - step: script: - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'." branches: master: - step: script: - sfdx force:org:create --targetdevhubusername HubOrg --setdefaultusername --definitionfile config/project-scratch-def.json -- setalias ciorg --wait 10 --durationdays 1 - sfdx force:org:display --targetusername ciorg #Push source to scratch org - sfdx force:source:push --targetusername ciorg #Run unit tests on scratch org - sfdx force:apex:test:run --targetusername ciorg --wait 10 --resultformat tap --codecoverage --testlevel $TESTLEVEL #Delete scratch org - sfdx force:org:delete --targetusername ciorg --noprompt feature/*: - step: script: - echo "Avoid anything scratch org stuff on feature/* pattern."
  • 29. Branch Permissions - Keep feature and other dev branches open for all. - Lock WRITE access to sensitive and final branches like UAT/Prod to a few responsible engineers. - They should code review and make sure no junk is coming in.
  • 30. - It’s good to document and agree on a branching model in the team. - Bitbucket helps with that, by clearly defining feature, hotfix, bugfix and release branches. Branching Model
  • 31. - How nice it will be to auto assign reviewers on pull requests. (pic below) Default Reviewers
  • 32. - REPO variables are used in CI scripting to access various normal and sensitive data. Bitbucket allows easy masking of sensitive information. Just check the “Secured” option when adding the variables. Safe Repo Variables
  • 33. More control on security “Deployments” feature allows one to - Tag env as Test, Staging and Prod - Have clear separation of env variables for each of them. Which are only editable by configured admins. - Fine permission control on which branches, people can deploy to that env.
  • 34. Integrations Allows Bitbucket to talk to your Bug Tracking or Build System. This option gives you ready made scripts to integrate with your Bug tracking or build tracking system. Mostly requires copying some API keys etc and setting up the env. Variable.
  • 35. Slack / Chat Alerts It’s no code, a simple OAuth with Slack will take it forward >
  • 36. Salesforce example uses Docker based pipelines config file. If your organisation works on Java, Python and other language, variety of sample pipeline config files are available, which work easily on gradle, maven etc. Multi Language Templates
  • 38. Q & A
  • 39. ● Official Salesforce Repo for Bitbucket Pipelines ○ https://github.com/forcedotcom/sfdx-bitbucket-package ● Continuous Integration with Salesforce DX ○ https://developer.salesforce.com/blogs/2019/05/continuous-integration-with-salesforce-dx.html ● Trailhead ○ https://trailhead.salesforce.com/en/content/learn/modules/sfdx_travis_ci ○ https://trailhead.salesforce.com/en/content/learn/modules/heroku-flow/learn-about-continuous-integration-deployment- and-delivery References