Git Repository

Updated 3 days ago by Iván Minaya

A Git Repository is a storage location where the versions of your files may be stored. This may be a hosted location or your own Git server.

Create a Git Repository in Copado

To create a Git Repository in Copado;

  1. Click on the Git Repositories tab.
  2. Click New
  3. Fill in all required fields
  4. Click Save

Copado will automatically perform a validation of your login credentials, and you will see the result of this validation when the page has loaded.

HTTPS

From your Git provider copy the HTTPS URL. In Copado, create a new Git Repository record and paste the HTTPS URL into the URI field, complete the Username and Password fields and then save the record. 

If you are running a hosted Git repository (not in the Cloud), make sure Port 443 is open. If you have IP Restrictions / Firewall / Layer 7, make sure the Copado IP Addresses can access the Git Repository URL. More information here.

AWS CodeCommitto connect CodeCommit repositories, copy the HTTPS clone url provided in the AWS Console, and then use the AWS Access Key as the Username and the AWS Secret Key as the Password.

Two-Factor Authentication to the Git Repository is not supported. The user added in the Git Repository record must have password authentication only enabled.

SSH

From your Git provider, copy the SSH URL. In Copado, create a new Git Repository record and paste the SSH URL into the URI field, then save the record. Now you need to create a new pair of keys, to do so, press the button "Create SSH Keys", once you have created the keys, click on the "view" link next to the "id_rsa.pub" file and copy the content. On your Git provider site, add the public key (id_rsa.pub), see screenshot below.

If you are running a hosted Git repository (not in the Cloud), make sure Port 22 is open. IP restrictions are not supported for SSH.

Retrieving Commit information into Copado

Having commit information within Copado allow users to compare commits, deploy from git among other functionalities.

Retrieved Commits are displayed as a related list right after the detail information. If you are running CI processes this information will be updated automatically. To retrieve commits manually, press the button "Retrieve Commits", wait a few moments and reload the page.

Deploy Commits

Copado allows users to create a deployment directly from a Git Repository record. To create a deployment press the button "Create deployment" and select a starting and ending  commit. Copado will create a deployment with 1 Git MetaData step including all committed files within those commits and will use the lat commit as the source. Optionally if there were deleted files, a Delete MetaData step will be created as well.

What to do when tracking other folders

When having other files within the git repository, that has nothing to do with the Salesforce metadata to be used for deployments, copado will ignore them so that your builds won't break. Copado will try to do the best to locate your salesforce root folder within your repository using different techniques. Nevertheless if Copado can't figure it out automatically, you can set the Copado root folder by simply creating an empty file named "copado_root" on the deployment root folder.

Quick Links to your Git Repository

Copado provides quick links to your git branches, commits, tags and pull requests in order to see relevant information in your Git repository provider's end. The quick links "View in Git" and / or "Pull Request" are found in the records of the following objects:

  • Git Snapshot (for the branch)
  • Snapshot Commit (for the commits)
  • User Story (for the feature branch if you are using Copado Git Flow)
  • User Story Commit (for the commits)
  • Promotion (in the deployments related list)

How to use it:

1. Go to your Git Repository record.

2. Select a Git provider (Github, Bitbucket, Gitlab, Microsoft Team Service, and Others)

  • Choose the "Others" option if working with Bitbucket Server or any other Git Service Provider. In the Pull Request Base URL, paste a sample pull request link from your Git Repository and replace the source branch with the variable "[TARGET_BRANCH_NAME]" and target branch name with the variable "[TARGET_BRANCH_NAME]"
  • For example:
    • Original URL: https://bitbucket.awsmgmt.yourcompany.com/projects/yourproject/repos/yourrepo/pull-requests?create&targetBranch=int&sourceBranch=dev1
    • URL with variables: https://bitbucket.awsmgmt.yourcompany.com/projects/yourproject/repos/yourrepo/pull-requests?create&targetBranch=[TARGET_BRANCH_NAME]&sourceBranch=[SOURCE_BRANCH_NAME]

    3. Fill the Branch Base URL, Commit Base URL, Pull Request Base URL, and Tag Base URL:

    4. Save the Git Repository record
    5. Navigate to one of your Git Snapshots, and find the "View in Git" field with the name of the branch. This link redirects to the branch page in the Git repository:

    6. Navigate to one of the commits in your Git Snapshot, and find the "View in Git" field with the id of the commit. This link redirects to the corresponding commit page in the Git repository.

    7. The User Story Commits record also has a View in Git link. The View in Git field is conveniently located in the User Story Commits related list in the User Story layout.


    8. A pull request link appears in the top layout buttons section in any User Story that has commits, in order to compare how the changes of an individual user story will affect the target Org when deployed. When clicked, you are redirected to the pull request page in your Git Repository. The pull request is populated with the feature branch of the user story and the target branch linked to the target environment, as defined in the Deployment Flow.

    9. A pull request link appears in any deployment located in the Deployment's related list of a Promotion record in order to compare how the promotion deployment will affect the metadata in the target Org. When clicked, you are redirected to the pull request page in your Git Repository. The pull request is populated with the promotion branch and the target branch linked to the destination environment of the Promotion.

    Extra Headers 

    You can include extra headers in the HTTP requests that the Git client performs by following these steps:
    1) create a Note against the Git repository record with name: "Extra Headers"
    2) add a Body with format: 

    <headerKey1>:<headerValue1> 
              <headerKey2>:<headerValue2>
              

    For example:

    token:123456
              key:abc

     Copado will then include the extra headers from the Note in the http requests to the Git Repository.

    Manage Git Branches

    As of v11, you can delete one or more branches of a Git Repository from the Copado application. More information here.

      Read Next: Git Snapshot

      How did we do?