Data Table

Salesforce Auto Deployment Using Gulp and VSCode

Topics

This post covers the topics below:

  • Intro
  • Clone repo
  • Install packages
  • Execute Gulp
  • Test Auto Deployment

Introduction

Salesforce introduces VSCode as a new development tool. Moreover, It allows us to download Salesforce files locally, make any changes and deploy updated files into Salesforce manually ( via right-clicking the updated file and choose the option to deploy changes file from the menu ). However, this manual process becomes cumbersome to see changes during Salesforce development.

Hence, I have created the gulp task runner which automate this manual process by automatic deployments of all changes every time the developers save the files locally.

Furthermore, this post covers how to use this custom task runner in every Salesforce development.

Prerequisite

1. Installed and configured the Gulp and Node.js.
2. Install and configured Visual Studio Code for Salesforce development.

Create Project with Manifest

  • open Visual Studio Code editor
  • Create a Project with manifest. 

Clone Repo

  • Then, clone the repo through this URL
  • Type command like image below in command prompt
Clone Process
  • Afer clone it, it adds a folder “vscode-AutoDeploy” in the project folder.
After Clone
  • Navigate into “vscode-AutoDeploy”.
  • Select all the files, then cut them by press ctrl+x
  • Navigate out from the “vscode-AutoDeploy” folder.
  • Paste the files in the root project. 
  • It prompts a message to “Replace or Skip Files” window.
  • Choose replace, and click ok.
Replace Files
  • Delete “vscode-AutoDeploy” folder. Because it is empty.
    Hence, the file structure is like image below:
Result File Structure
tasks-runner

Install packages

Type command below in the command prompt:

npm install

Authorise an Org

  • Press ctrl + shift + p, after that type “sfdx:authorize”.
  • Choose “SFDX: Authorize an Org”
authorize
  • It prompts command pallete to choose type of org. 
  • Accept default login URL or other org type as your need.
Org Type
  • Enter alias name such as – vsCodeDev.
  • It prompts a web browser that navigate to Salesforce login page. Then, put existing user’s credential.
  • Close the web browser
  • Open up Visual Studio Code, look at the command prompt.
  • It displays that “Authorize has successful” at Output tab.

Run Auto Deployment to Salesforce

Command Prompt
  • In the terminal of Visual Studio code, type command below in command prompt:
gulp

The command above executes task runners are executed in the order below:

  1. retrieve all files from Salesforce.
  2. watch for changes in any files in the project folder.

If retrieve successful, it displays a list of files that are retrieved from Salesforce similar to the image below:

Retrieve SF Files

Test Auto deployment

Test if auto-deployment works by making changes in any file in the project folder.

1. Open any apex file that is retrieved from Salesforce in VSCode.
before save

2. Make any changes and save the file by press ctrl + s

Auto Save

Leave a Reply