> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FlexDeploy - Git Plugin Guide

> The FlexDeploy Git plugin makes it easy to interact with source code stored in a Git repository. This plugin requires a Git client to be stored on the

The FlexDeploy Git plugin makes it easy to interact with source code stored in a Git repository. This plugin requires a Git client to be stored on the FlexDeploy server and any endpoints which will execute Git plugin operations. FlexDeploy allows users to configure Git repository connection details to be shared by various projects and other configurations at a project level.  This allows workflows to perform clone and tag operations within a workflow.

* Create SCM Instance for Git and define URL, User and Password information. You can also validate connection when creating SCM Instance for Git.

* At project level, select Git as SCM Type and provide details like Branch, Sparse Folders, Tag etc. which are defined as Groovy scripts.

> [!TIP]
>
> See [Using SSH protocol with GitHub](https://docs.flexagon.com/flexdeploy-11-2-documentation/flexdeploy-plugin-guides/flexdeploy-git-plugin-guide/using-ssh-protocol-with-github.md) to setup SSH connectivity to GitHub.
>
> See [Using SSH protocol with Bitbucket](https://docs.flexagon.com/flexdeploy-11-2-documentation/flexdeploy-plugin-guides/flexdeploy-git-plugin-guide/using-ssh-protocol-with-bitbucket.md) to setup SSH connectivity to Bitbucket.

# Supported Versions

* 1.7.9+

# Key Features

* Executes native commands using Git client

* Supports partial (sparse checkout) and shallow checkouts from Git Repository

* Integrates with on-prem or cloud Git repositories. Seamless integration with GitHub, GitLab, Azure DevOps, Oracle Developer Cloud Service, Bitbucket etc.

# Integration Instance Properties

<table><colgroup><col /><col /><col /></colgroup><tbody><tr><th>**Property Name**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>`FDGIT_URL`</td><td>Yes</td><td>The URL to the remote GIT repository.</td></tr><tr><td>`FDGIT_USER`</td><td>Yes</td><td>The username to the remote GIT repository.</td></tr><tr><td>`FDGIT_PASSWORD`</td><td>Yes</td><td>The password for `FDGIT_USER`. This also accepts Personal Access Tokens, many Git providers now require use of Personal Access Tokens instead of Passwords.</td></tr><tr><td>`FDGIT_PRIVATE_KEY`</td><td>No</td><td>Private key used to connect to Git. Make sure that associated public key is configured on Git account. Git URL must start with `ssh://` or `git@` in order for this input to show up on the UI.</td></tr><tr><td>`FDGIT_TIMEOUT`</td><td>No</td><td>Timeout (milliseconds) for Git command execution, if not specified it defaults to one hour.</td></tr><tr><td>`FDGIT_COMMIT_URL`</td><td>No</td><td>Commit URL is automatically derived for GitHub, GitLab, Bitbucket, Azure DevOps, Oracle Developer Cloud etc. For other providers or on-prem installations, you should configure this property.Git Commit URL. Able to use the following variable \{COMMIT}e.g. `https://repo.mydomain.com/MyOrg/FD-REPO/commit/\{COMMIT\}`</td></tr><tr><td>`FDGIT_FILE_CONTENT_URL` <sup>1</sup></td><td>No</td><td>File URL in Git repository is automatically derived for GitHub, GitLab, Bitbucket, Azure DevOps, Oracle Developer Cloud etc. For other providers or on-prem installations, you should configure this property.Git Repository File URL. Able to use the following variables \{BRANCH} \{FILEPATH} \{SPARSE\_CHECKOUT\_FOLDERS}e.g. `https://repo.mydomain.com/MyOrg/FD-REPO/blob/\{BRANCH\}/\{SPARSE_CHECKOUT_FOLDERS\}\{FILEPATH\}`</td></tr><tr><td>`FDGIT_FILE_CONTENT_COMMIT_URL` <sup>1</sup></td><td>No</td><td>Commit URL for File is automatically derived for GitHub, GitLab, Bitbucket, Azure DevOps, Oracle Developer Cloud etc. For other providers or on-prem installations, you should configure this property.Git Repository File URL for Commit. Able to use the following variables \{BRANCH} \{FILEPATH} \{SPARSE\_CHECKOUT\_FOLDERS} \{COMMIT}e.g. `https://repo.mydomain.com/MyOrg/FD-REPO/commit/\{COMMIT\}`</td></tr></tbody></table>

1 - If customization is needed, set both `FDGIT_FILE_CONTENT_URL` and `FDGIT_FILE_CONTENT_COMMIT_URL`. If only one of this property value is set, then Repository URL will be shown as File content link.

# Target Properties

<table><colgroup><col /><col /><col /></colgroup><tbody><tr><th>**Property Name**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>`FDGIT_CMD_PATH`</td><td>No</td><td>The GIT executable folder.\
Note: If the Git executable is on the `PATH`, then there is no need to setup this property, otherwise, this needs to be configured on the targets screen for the workflow instance (different from the 3 above, which are on the SCM Instances screen).</td></tr></tbody></table>

# Plugin Operations

# Git Installation Steps

Git 1.7.9 or higher is needed for FlexDeploy. If yum installs a lower version by default, then you need to get the Git source code and build it for install. Here is reference - [https://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/](https://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/).

Run these steps as root. You can download a newer version than 2.7.1 as well.

1. yes | yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

2. yes | yum install gcc perl-ExtUtils-MakeMaker

3. cd \$HOME

4. wget [https://github.com/git/git/archive/v2.7.1.tar.gz](https://github.com/git/git/archive/v2.7.1.tar.gz)

5. tar -xvzf v2.7.1.tar.gz

6. cd git-2.7.1/

7. make prefix=/usr/local all

8. make prefix=/usr/local install

> [!NOTE]
>
> On some other target groups including some Oracle Cloud instances, it may be necessary to either change lines 7+8 by removing the /local or by adding symlinks in /usr. The git executable must be on the path without running the .bash\_profile or any other scripts because FlexDeploy won't run those scripts when SSHing to the endpoint.

# Token Authentication for GitHub

Personal access tokens (PATs) are an alternative to using passwords for authentication to GitHub when using the GitHub API or the command line. 

To create a Personal access token, follow [https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)

While generating Key Scope items is completely based on your requirement.

Basic permission to grant this token is required, Repo- Full control of private repositories

Admin:repo\_hook- read:repo\_hook read repository hooks for a clone, if you are doing commit from FlexDeploy then you need write:repo\_hook

Once token is generated, Update GIT password property with the token value on specific GIT Instance under Topology - Integrations - Source Control.

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590936070.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=bde57f92e16b991e0a095935dd55b3dd)

# Multiple SSH Keys for different repositories

> [!TIP]
>
> It is recommended to use `FDGIT_PRIVATE_KEY` on GIT source control instance now.

If you have more than one source control account with the same domain name (i.e. github.com, bitbucket.org, etc) and wish to use a different SSH key for each account follow the below instructions:

1. Generate your SSH keys if you have don’t have them already. SSH key must be RSA algorithm (ssh-keygen -t rsa). It’s recommended to store the SSH keys in the .ssh folder.

2. Ensure \<FlexDeploy\_User\_Home/.ssh folder exists. The .ssh folder should already be there in the home directory since \~/.ssh directory is automatically created when the user runs the ssh command for the first time. If the directory doesn’t exist on your system, create it using the command below:

   ```
   mkdir -p ~/.ssh && chmod 700 ~/.ssh
   ```

3. Create the configuration file name “config” in the \<FlexDeploy\_User\_Home>/.ssh/ directory of the user running FlexDeploy, if it doesn’t already exist.

   * The SSH config file takes the following structure:

     ```
     Host hostname1
         SSH_OPTION value
         SSH_OPTION value

     Host hostname2
         SSH_OPTION value

     Host *
         SSH_OPTION value
     ```

   * Add the appropriate entries for your organization and use case. In this example, we’ll add one entry with Host “bitbucket-alt”

     ```
     Host bitbucket-alt
       HostName bitbucket.org
       IdentityFile ~/.ssh/<your_SSH_key>
       IdentitiesOnly yes
     ```

4. On the account instance, set Host value in the URL.

I.E. ssh://git\@bitbucket-alt/flexagon/dummy-repo.git

Effectively, you can use alternate SSH key for any SCM account by changing the URL.
