Deployment Process in Multi-Cloud

Updated 3 weeks ago by Copado Solutions

In the article Commit Process in Multi-Cloud, we described what the overall commit process in Multi-Cloud looks like and the different options available to commit your changes. In this article, we will explain how the deployment process works once you have committed your changes.

Deployment diagram

As with the commit process, you can use the CLI or the UI to promote and deploy your changes, or promote and deploy them programmatically. Let’s describe these options in more detail.

Promoting & Deploying from the UI

If you want to promote and deploy your changes using the interface, you can do so using one of the following options:

  • Select the Promote and Deploy checkbox on the user story to deploy a single user story straight away. Copado will automatically create a Promotion record and deploy the user story.
  • If you want to promote more than one user story in the same transaction, you can flag the user stories as promotable by selecting the Ready to Promote checkbox and then create a promotion manually or from the Pipeline page to deploy them. Let’s review these two options in more detail.
Creating a Promotion Record

If you want to create a Promotion record and add the user stories you want to deploy manually, follow these steps:

  1. Navigate to the Promotions tab and click on New.
  2. Select a release, if desired, a project and a source environment.
  3. Save the record.
  4. Copado will populate the platform based on the platform selected in the pipeline linked to the project you added in step #2. Your record should look like this:
Multi-Cloud promotion record

  1. Then, navigate to the User Stories tab to add the user stories you want to include in the promotion. Only the user stories that have been flagged as Ready to Promote will be available for selection:
    User Stories Tab
  2. Once you are done, you can perform one of the following actions:
    Actions on the Promotion page
    1. Merge Changes: If you click on Merge Changes, Copado creates the promotion branch and merges all the feature branches of the user stories included in the promotion with the promotion branch.
    2. Deploy Changes: You can choose this option to complete the deployment if you have already merged the changes. Copado will deploy the changes to the destination environment and will merge the promotion branch with the branch of the destination environment if the deployment is successful.
    3. Merge & Deploy Changes: This last action is a combination of the two actions above. If you click on Merge & Deploy Changes, Copado creates the promotion and merges all the feature branches, then, it deploys the changes to the destination environment and, if the deployment is successful, merges the promotion branch with the branch of the destination environment.

Creating a Promotion from the Pipeline Page

To create a promotion from the Pipeline page, follow these steps:

  1. First, ensure the user stories you want to promote have been marked as Ready to Promote.
  2. Then, navigate to the Pipeline record and click on the Pipeline Manager link to open the Pipeline page.
  3. Click on the right arrow (left arrow if you want to create a back-promotion) next to the environment from which you want to promote user stories.
  4. A page where you can see all the user stories in that particular environment that are ready to be promoted will open. Select the user stories you want to promote and click on Create Promotion.
    Create Promotion
  5. Copado will create the Promotion record and redirect you to it. From there, you can choose one of the options defined above, Merge Changes, Deploy Changes or Merge & Deploy Changes.

Promoting & Deploying from the CLI

To promote and deploy a user story using the CLI, you can use the command sfdx copado:work:submit -d.

Promoting and Deploying from an Automated Process

To execute a promotion or a deployment programmatically, you can invoke the Copado actions from a flow or call these actions via Apex.

Flow

Drag an Action element to the canvas and select one of the following actions:

  • Run a Copado promote to execute a promotion.
  • Run a Copado promotion deployment to execute a deployment.

See below how these two actions look like:

Promote Action in a Flow

Promotion Deploy Action in a Flow

Apex

To execute a deployment from Apex, you can use the below snippet:

copado.PromoteAction.Request cr = new copado.PromoteAction.Request();
cr.promotionId = promotion.Id;
cr.executePromotion = true;
cr.executeDeployment = true;
cr.deploymentDryRun = true;
cr.otherInformation = '{“packDeploy”: false}';
List<copado.PromoteAction.Response> resp = copado.PromoteAction.promote(new List<copado.PromoteAction.Request>{cr});

If you don’t have a variable defined for the promotion Id, simply replace the variable in line number 2 with the actual Id of your Promotion record:

E.g., cr.promotionId = 'a0q5I000001MPDgCIA';

You can set the following variables to true or false depending on whether you want to execute a validation deployment or a real deployment. For instance, if you configure the variables as below, Copado will perform a real deployment:

cr.executeDeployment = true;

cr.deploymentDryRun = false;

Now that you know how you can deploy your changes, take a look at the Conflict Resolution in Multi-Cloud article to learn how conflict resolution in Multi-Cloud works.


How did we do?