Delete Components

Updated 4 months ago by Iván Minaya

Delete components with User Stories or Deployments

When files are committed in a user story, a feature branch is created and the files are committed there. Right after that, the feature branch is merged into the source branch therefore, after committing files, the feature branch and the source branch will contain the components that were committed.

With Copado v11, you can use the Destructive Changes feature to remove components in Git and the Organizations. You can find more information about this feature in the Copado Git Operations documentation.

If you are in a previous version of Copado, you have the options below.

Scenario #1.

Files are committed in the User Story and the User Story is promoted and deployed until production. Now you want to remove a component that was deployed with that user story until production.

If the component that you want to delete is a file in the Git repository (for example a profile or a page layout), you can do the following.

  1. Delete the file in the git branch of the lowest environment and commit the changes.

  2. Go to the Git Snapshot associated to that branch and Retrieve Commits. The commit of the deletion will appear in the Git Snapshots Commits.

  3. Create a new User Story and use the button Add Commits.

  4. Select the Delete Commit. The component will appear as Git Deletions under the User Story Selections of the User Story

  5. Promote and Deploy the User Story.

  6. The component will be removed in the target org but not from the target branch. You need to delete the file manually from the target branch. Keep doing the same until production.

Scenario #2.

If the component is a nested component in Git, for example a custom field the way to proceed would be the following:

You can delete the custom field in the target orgs using a deployment with the step Delete Metadata. The source org is the lowest environment and the target orgs are all the orgs where you want to delete the field including the source org.

  1. Create a deployment.

  2. Create a Delete Metadata step.

  3. Select the field that you want to delete and deploy.

  4. Once the deploy is completed, you need to delete the field from the branches manually since the deployment is not updating the branches. In addition, a global find a replace rule can be added to skip that field from git until all branches are cleaned up.

Remove components from User Story Selections in User Story.

You have committed several components in the User Story and you want to remove one of the components because you do not want to promote and deploy that component or that component is causing issues in the deployment.

With Copado v11 you can use the feature Recommit Files in the user story with the option Re-create Feature Branch.  In the list of pre-selected components (these are the components committed previously), deselect the components that you want to remove from the user story. When you click on the Commit button, a new feature branch will be created for that user story and the selected components will be committed. The components that were deselected will be removed from the user story selections.

More information about the Recommit Files feature in the Copado Git Operations documentation.

If you are in a previous version of Copado, you have the options below.

Option #1.

  1. Go to the source branch where the component was committed and remove the component. This is done to keep the branches in sync.

  2. Delete the feature branch in Git.

  3. Go back to the user story record and commit again the components, this time do not include the component you want to remove. The feature branch will be recreated again, this time without that component. There is a Recommit (as from v.7.1) list button accessible from any list view of User Stories.

  4. Once the components have been committed, in the user story, scroll to the related list "User Story Commits" and remove the previous user story commit record(s) so that only the components in the latest commit appear in the User Story Selections list.

  5. In the user story, click on Refresh Git Selections. You may need to click a few times since it takes some time for the list to be updated.

Option #2.

The User Story Selection list in a user story is the sum of all the components in the user story commits. The components on each user story commit are taken from the attachment of the Snapshot Commit associated to the user story commit.

You can follow this steps to remove specific components from user stories without removing the entire feature branch.

  1. Edit the feature branch and remove only the components you do not want to deploy.

  2. Open the specific user story commit that contain the components you want to remove in the user story.

  3. Open the Snapshot Commit linked to that user story commit.

  4. There is an attachment in the Snapshot Commit that contains the components that were committed.

  5. Download and Edit the attachment to remove the component.

  6. Save the attachment file with NO extension.

  7. Remove the old attachment.

  8. Upload the new attachment.

  9. In the user story, click on Refresh Git Selections. You may need to click a few times since it takes some time for the list to be updated.

How did we do?