How to execute git commands outside of the git connector

Requirement:

Customers may require the need to execute git commands (in particular: git lfs fetch) after a git repo is cloned by Harness in a pipeline.

Solution:

This can be done using 2 options

First Option is to use a Run Step:

- step:

2 type: Run

3 name: git lfs pull

4 identifier: git_lfs_pull

5 spec:

6 connectorRef: account.Docker_Hub

7 image: alpine/git

8 shell: Sh

9 command: |-

10 mkdir -p ~/.ssh

11 cat << EOF > id_rsa

12 <+secrets.getValue("account.BitbucketGithubSSHKey")>

13 EOF

14 mv id_rsa ~/.ssh

15 chmod 600 ~/.ssh/id_rsa

16 ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

17 git config --global user.email "automation@abc.com"

18 git config --global user.name "Automation User"

19

20 git lfs pull

Another option is a Drone plugin created by martin.ansong@harness.io, one of our engineers.

Plugin name: mansong/git-plugin