Salesforce DX is changing the way developers used to code and making it better in terms of team collaboration, source driven development and faster testing and deployments.

There are multiple development models in Salesforce namely change set, Package, App and Org development model. Lets see the new App and Org development models in detail:

Org Development Model

Setup tools:

  • Salesforce CLI
  • VSCode (Install Salesforce CLI, Package Manager)
  • Gitlab Account (Gitbash)
  • OpenSSH

Gitlab setup:

  • Create an empty repository.
  • Open GitBash on Windows and use the below command
  • ssh-keygen -o -f ~/.ssh/id_rsa
    This will ask for ra passphrase which will be used in all git push commands.
  • Upload the public key in GitLab account UI.
  • Create a workspace directory in local machine and use below command when needed
    git init
    git clone
    git checkout -b name-of-branch (For new branch)
    git checkout name-of-branch (For using existing branch)
    git add .
    git commit -m “comments”
    git push remote name-of-branch OR
    git push origin master

VS Code Steps

  • From command palette create SFDX: Create Project With Manifest
  • Make sure .gitignore has entry for below:
    • .sfdx/
    • .vscode/
  • Use SFDX Authorize from command palette to authorize your sandbox and set an alias for it.
  • Fetch metadata using package.xml
  • Push/Commit changes to master/branch.

Deploy Changes

  • Authorize the full sandbox/production.
  • Convert to metadata format using below command

sfdx force:source:convert --rootdir force-app --outputdir tmp_convert

  • Convert the output to .zip file using command or manually.
  • Delete the converted output dir using command or manually rmdir /s tmp_convert
  • Run deployment using below command

sfdx force:mdapi:deploy --zipfile --targetusername sge-prod --testlevel RunSpecifiedTests --runtests TickeraIntegrationControllerTest


sfdx force:mdapi:deploy --zipfile --targetusername partial-sandbox --testlevel RunLocalTests

  • Deploy after validation success using below command

sfdx force:mdapi:deploy --targetusername production-org --validateddeployrequestid jobID

Configure Gitlab CI/CD

  • Generate private key and self signed digital certificate using OpenSSL tutorial below:

  • Create Connected App in Salesforce using tutorial below:

  • Run below commands:

sfdx force:auth:jwt:grant --clientid 3MVG9HxRZv05HarRDiSdWT3fU.wlTDceC8qD380x9NSS5uk5o3JB2zlbXV4Nr8.v9mOToGIJgs3PKsn.WB6Q6 --jwtkeyfile E:/GITLAB/SFDX/JWT/server.key --username --setdefaultdevhubusername

sfdx force:package:create --path force-app --name "sge-prod" --description "GitLab CI Package Example" --packagetype Unlocked