Harness Git Sync. Best Practices,Do's and Don'ts

What is Harness Git Sync?

Harness Git sync comes handy when users start adopting Harness in large scale. The best practice that we suggest is it to create a golden application/pipeline for each deployment stream sync and sync them to your Git repo. When you are ready to on-board new teams - all you need is to create a new application in Harness and use the golden pipeline setups cloned to this new repository. That’s it and you are set. Your entire pipeline, workflow and all the other deployment components are ready, this will help user to deploy application source code to different life cycle like development, stage, UAT and production in a matter of few minutes to less than an hour depends on the process implemented.

For the first time Harness always push the configuration from Harness User interface to Git sync, any existing changes in Git will be over written. We Always suggest to start from Harness User Interface and add or overwrite changes after first push from harness to Git successful. Harness will sync the change from Git on subsequent commits.

Step by Step Guide

  • Create Golden Application/ Pipeline : Identify different deployment swim lanes like AMI, ECS, Kubernetes, etc…, and create an template application which covers all deployment steps in a generic manner externalize the micro services and parameters using workflow variables.

  • Git Sync : Identify or create a git repository in which all Golden Application/Pipeline source code can be stored and managed and configure required Git connector in Harness upfront. Once connector is in place enable the git sync in Harness User interface (choose appropriate branch as needed)

  • Application Onboarding with Golden Application: Given that the golden application is in place, now the application use the same deployment process flow (swim lanes) can leverage them and get started with deployment to multiple environments like dev, stage and production quicker. Here is the steps that will guide user to achieve this

    • Create a New Git repository or choose an existing git repository to manager new Onboarding applications harness configurations and create a new git connector in Harness User Interface

      Harness expects at-least one commit performed in the repository, here in this example i had added README.md file

      Create Git connector in Harness

  • Create a new Application in Harness and configure Git sync, Harness will create skeleton application with basic configuration required. Once application creation is completed harness will push the skeleton configuration to git repository.

  • Copy the contents cloned from the Golden Application / Pipeline using git command line and commit the source code and push to remote repository, allow few moment for harness to sync and create require Harness components.

    • Copy and modify the configurations from Golden application and commit the changes and push to remote repository. The Web hook configured in Git will push the changes to harness and harness process all application components asynchronously.

    • Allow few moments for harness to process, Harness will create all required components configured from git YAML. All set to go ahead start deployment with Harness

  • Troubleshoot Git Sync issue :

    • Since Harness process the resources in asynchronously few errors like listed below are expected but retry mechanism should take care of the issue in net iteration. If issue persists even after multiple retry the issue listed needs to fixed in git repo.

    • Creating a git repository by cloning the golden application before creating harness application and enable git sync will be overwritten by Harness as always harness assume that Change in the User interface is latest. In order to overcome you might need to reset the git head to pervious version and do dummy commit which will push all changes to harness again.Here is the step by step guide

  • Known Limitations

    • Harness use ids to refer secrets, Jira connectors.etc.,and these id’s are visible in the git sync yamls. Git sync within single account id works perfectly fine. Presence of this id restricts the ability to use git sync in account or multiple harness installation agnostic solution. In order to use with different accounts or installation user need to spend time to update id’s in all YAML’s before performing commit git repository. This is an extensive manual work but our engineering team is determined to fix it in one of the upcoming releases.

    • In order to use with different accounts or installation you need to update id’s in all YAML’s before performing commit git repository. This will be fixed in one of the upcoming releases.