How to push Work-In-Progress Back to Refreshed Org

Overview

This article describes how to deploy changes committed to a feature branch back to a sandbox.  These steps can be used when an org is refreshed, but there were changes committed to a user story before the refresh and it allows users to update their sandbox with their work-in-progress that would have otherwise been lost.  
You have different methods to be able to do this. 

Prerequisites

If you refreshed an environment - follow the steps on this article before continuing. 

Which option should I follow? 

Taking as example this environment diagram:

User-added image

Ask yourself the following:
  • Are the user stories in an environment with more than 1 sandbox pointing to it like integration in the environment diagram?
    • Yes - Option 1
    • No - Next Question
  • Are the user stories in the lowest environment, that is Dev1 or Dev2 in the environment diagram? 
    • Yes - Option 3
    • No - Option 2
 

Option 1: Back Deploying Changes (Best Practice when available) 

Use Case: This option must be chosen when back deploying from a sandbox that has multiple sandboxes pointing at it. The lowest environments, Dev1 or Dev2, were refreshed and your user stories were already deployed to Integration (contain work in progress). Now you want to take the user stories that are in Integration and push them back to Dev1 and Dev2.

Steps:
  1. Create a list of user stories you would like to sync back to your refreshed org
  2. Open the Pipeline Manager
  3. Click “Mass Back Promote” 
  4. Click the “Disable Auto Selection Overwrite” button and select the user stories you would like to back promote to the refreshed sandboxes. Note: clicking the Disable Auto Selection Overwrite button will allow you to back deploy user stories to the same environment they came from!
  5. Click on "Back promote and Deploy". 

Option 2: Fake promotion - back promotion

Use Case:  You have been committing a lot of changes to user stories over the last month but your user stories still lie in Dev1 and haven’t deployed them to Integration. Dev1 was refreshed and you need to get my work in progress from the user stories back to Dev1. 

Steps:
  1. Create a list of user stories you would like to sync back to your refreshed org.
  2. Mark all user stories as “Ready to Promote” 
  3. Go to the promotion tab and create a new promotion
  4. Choose as source org the refreshed org (dev1) and the project assigned to the pipeline containing the refreshed org. 
  5. Click the “Add User Stories” tab and add the user stories to the promotion. 
  6. Update the Promotion Status as “Completed”. Note: This simulates a successful promotion. The Pipeline Manager will display the selected user stories as if they had been promoted to the target org (Integration in this example) based on the pipeline connections. The result is that the selected user stories are now available to select for back promotion from the target org (Integration).
  7. Open the Pipeline Manager
  8. Click “Mass Back Promote” .
  9. Click the “Disable Auto Selection Overwrite” button and select the user stories you would like to back promote to the refreshed sandboxes
  10. Click on "Back promote and Deploy".
  11. After the back deployment is complete, update user stories’ org credential and environment back to their original sandboxes. This will allow you to perform a true promotion to the integration environment. 

Option 3: Deploying a single US from Branch (available for more scenarios)

Important note: It’s not possible to deploy nested components with this option. 

Use Case:  You have been committing a lot of changes to user stories over the last month but your user stories still lie in Dev1 and haven’t deployed them to Integration. Dev1 was refreshed and you need to get my work in progress from the user stories back to Dev1. 

Steps:
  1. Determine the branch you would like to deploy from and make a list of those branches Example: feature/US-0000029
  2. From the org where copado is installed, click on the Git Repository record tied to your active pipeline. 
  3. Click on "Retrieve Commits". 
  4. Type in or copy paste the feature branch name into the window. 
  5. Click on "Submit" to retrieve all commits tied to the feature branch. 
  6. From the same page, click on "Create Deployment".
  7. Fill in the branch field with your branch name and then click off the branch in the white space. Note: This will filter by the branch and show the commits that are on the branch. You’ll notice a lot of commits, because it is showing all commits from the master branch as the feature branches are created off the master branch.
  8. Review the commits with the Commit message of your user story. 
 
User-added image
 
  1. Select the oldest commit with your user story number in the commit message (lowest one on the screen)
  2. Select the newest commit with your user story number in the commit message (highest one on the screen)
  3. Click Create Deployment
  4. Navigate to the Deployment Tab
  5. Look for a deployment with the Name “Git Deployment” and click into that deployment
  6. Update the name of the deployment (e.g Best Practice = “User Story Name → Sandbox Name + short message”)
  7. Add “To Org” or the org where you are wanting to deploy the changes to. 
  8. Click on "Deploy" and then "Deploy All” .
You are required to perform an additional step in order to keep the org branch in sync with the org. 
  1. Open the user story US-0000029. 
  2. Click on "Commit Changes" and select recommit operation. 
  3. Set "Re-create Feature branch" to true. 
  4. Click Commit Changes. 
  5. This will recommit the files that you just deployed to the org and update the org branch so it is in sync with the org.

How did we do?