Reader small image

You're reading from  DevOps for Salesforce

Product typeBook
Published inSep 2018
Publisher
ISBN-139781788833349
Edition1st Edition
Concepts
Right arrow
Authors (2):
Priyanka Dive
Priyanka Dive
author image
Priyanka Dive

Priyanka Dive is a DevOps engineer with substantial experience of working in the IT field on various technologies, such as Docker, Kubernetes, Jenkins, AWS, and Azure. She has worked on big data projects as a system and DevOps administrator. She has worked on Salesforce projects and implemented DevOps practices for small and large projects as well. She's a constant learner with a desire to learn anything new, and hence enjoys doing a lot of tech POCs. She is also a technical blogger who loves to write on emerging technologies. She is currently working as a DevOps Engineer Consultant for a US-based firm.
Read more about Priyanka Dive

Nagraj Gornalli
Nagraj Gornalli
author image
Nagraj Gornalli

Nagraj Gornalli is a Team Leader at Persistent Systems on Salesforce projects. He has more than eight years' experience in the IT field with different technologies. He has done many certifications' such as Salesforce Certified Administrator, Salesforce Certified Platform Developer, Salesforce Certified Sales Cloud Consultant, Data Integration Specialist, Advanced Apex Specialist, Data Integration Specialist, and cloud certified professional. He started as a trailblazer and is now ranked as a "Ranger" in trailhead.
Read more about Nagraj Gornalli

View More author details
Right arrow

Chapter 3. Deployment in Salesforce

In the previous chapter, we discussed the need for DevOps in Salesforce application deployment, and different scenarios where DevOps can make it easy for a large number of developers to work on the same project. We saw that DevOps can give us streamlined delivery, helping us track application issues with open source tools. We also took a look at how Salesforce is different from other technical stacks. We went through the process of setting up DevOps for the Java development stack using Git and Jenkins.

In this chapter, we are going to discuss how to deploy Salesforce code from one sandbox to another sandbox, or from a sandbox to production, in a transitional way. There are various ways to deploy code, such as using Change Sets or a migration tool.

In this chapter, we will learn about the following topics:

  • What is deployment with reference to DevOps?
  • Deployment from sandbox to sandbox and sandbox organization
  • Deployment using Change Sets
  • Deployment using a migration...

What is deployment with reference to DevOps?


Successful deployment of code changes to a production environment involves many tasks, such as unit testing, integration testing, configuration changes, avoiding downtime, taking a backup of the existing environment to avoid data loss in the event of failed deployment, provisioning to revert changes quickly, and so on. In DevOps, with the help of many deployment, configuration management, backup, and restore tools, it is easy to perform fast, zero-downtime deployments.

In DevOps, continuous deployment is the process of deploying every change from a development environment to a production environment, where every change goes through the pipeline of continuous integration, with testing happening automatically. This process allows us to deliver new features and bug fixes to a production environment more quickly.

As every change goes through the DevOps pipeline, everything is tracked. For example, say we wanted to deploy Java application code from a...

Deployment in Salesforce


There are many different ways to deploy Salesforce in production. Salesforce deployment involves simply moving Salesforce metadata to production.

There are three ways to move metadata to production:

  • From a sandbox to a Production Org
  • From one Production Org to another Production Org
  • From a developer org to a Production Org

 

There are various methods to achieve Salesforce metadata deployment:

  • Change Sets
  • The Ant Migration Tool
  • The Force.com IDE
  • Third-party tools that use the Metadata API or the Tooling API
  • The SOAP API
  • Visual Studio Code with Salesforce DX plugins

Change Sets

To use a Change Set, a sandbox must be connected to a Production Organization. In the previous chapter, we discussed creating a sandbox and creating a connection between the sandbox and production organization. This is the traditional and most simple way to send configuration and metadata changes from one sandbox to another or from one sandbox to a Production Organization.

There are two different types of...

Deployment using the Ant Migration Tool


The Ant Migration Tool provides a way to deploy metadata from the local directory to a Salesforce sandbox. We can use the Ant command-line utility to automate deployment tasks in Salesforce.

The Ant Migration Tool helps us to retrieve and deploy metadata to and from a sandbox.

This tool can also be used to take backups of your sandbox metadata. To configure access to the sandbox, we need to provide sandbox credentials in the build.properties file. The build.xml file contains commands for retrieving or deploying metadata. Package.xml contains the components to be retrieved or deployed. 

 

The Ant Migration Tool is explained in detail via an example in Chapter 4Introduction to the Force.com Migration Tool

We will discuss some scenarios where the Ant Migration Tool deployment type can be used:

  • Deployment can involve many setup changes, but using the web interface to make those changes is a difficult and time-consuming job. The Ant Migration Tool can be...

Using the Force.com IDE to deploy Apex


The Force.com IDE is a plugin for the Eclipse IDE. The Force.com IDE provides a unified interface for building and deploying Salesforce applications. Designed for developers and development teams, the IDE provides tools for accelerating Salesforce application development, including source code editors, test execution tools, wizards, and integrated help. This tool includes basic color-coding, outline view, integrated unit testing, and auto-compilation on save with error-message display capability.

The Force.com IDE is a free resource provided by Salesforce to support its users and partners, but isn't considered part of our services in terms of the Salesforce Master Subscription Agreement.

To deploy Apex from a local project in the Force.com IDE to a Salesforce organization, use the Deploy to Server wizard.

If you're deploying to a Production Organization, at least 75% of your Apex code must be covered by unit tests, and all of those tests must complete...

Installing Salesforce DX plugins to Visual Studio Code


Perform the following steps to set up Visual Studio Code:

  1. Download and install the latest version of Visual Studio Code from https://code.visualstudio.com/download.
  1. After installation, open Visual Studio Code and, on the left toolbar, click the Extensions icon. Search for Salesforce Extensions for VS Code:

Search results for Salesforce Extensions for VS Code

  1. Click on the relevant Install button to install the extension pack:

Installing the required extension

  1. Once the installation is complete, click on the Reload button:

 

 

Summary


In this chapter, we learned about how to deploy Salesforce code from one sandbox to other sandbox, from the sandbox to a Production Organization, and from one organization to another organization. We were introduced to the different types of code deployment. We also learned how to use them depending on the type of project. We learned about how we can use Change Sets and the Force.com IDE to move code to production when we are working on projects where we need to continuously move code to production, such as in an ongoing project.

In the agile methodology, we mostly use the Ant Migration Tool, enabling code to be moved at specific intervals or in sprints. In the next chapter, we will discuss the Ant Migration Tool in greater depth.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
DevOps for Salesforce
Published in: Sep 2018Publisher: ISBN-13: 9781788833349
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Priyanka Dive

Priyanka Dive is a DevOps engineer with substantial experience of working in the IT field on various technologies, such as Docker, Kubernetes, Jenkins, AWS, and Azure. She has worked on big data projects as a system and DevOps administrator. She has worked on Salesforce projects and implemented DevOps practices for small and large projects as well. She's a constant learner with a desire to learn anything new, and hence enjoys doing a lot of tech POCs. She is also a technical blogger who loves to write on emerging technologies. She is currently working as a DevOps Engineer Consultant for a US-based firm.
Read more about Priyanka Dive

author image
Nagraj Gornalli

Nagraj Gornalli is a Team Leader at Persistent Systems on Salesforce projects. He has more than eight years' experience in the IT field with different technologies. He has done many certifications' such as Salesforce Certified Administrator, Salesforce Certified Platform Developer, Salesforce Certified Sales Cloud Consultant, Data Integration Specialist, Advanced Apex Specialist, Data Integration Specialist, and cloud certified professional. He started as a trailblazer and is now ranked as a "Ranger" in trailhead.
Read more about Nagraj Gornalli