Add Custom Template Library
This document will walk you through the steps required to setup a new custom Harness Template Library and connect it to your Harness Solutions Factory deployment.
A Custom Harness Template Library repository is included with the deployment of your Harness Solutions Factory. This repo contains a copy of this documentation along with additional configuration files intended to help streamline the setup of new or modified Template Library entries.
Note: If you do not have a Custom Harness Template Library repo in the root of your Harness Platform Management organization, then proceed to the documentation on How to upgrade your Solutions Factory implementation
Note: When configuring the Solutions Factory implementation for the first time, the custom-harness-template-library will import the original source repository directly into the repo. The source for this repo can be found in Github here. Subsequent updates to the Solutions Factory installation will not synchronize any changes in this repository.
Leverage your own Source Code Manager
In order to leverage your own Source Code Manager, you will be required to configure several pre-requisites prior to utilizing any templates stored in that repository.
Note: The steps detailed here will assume that you have permissions to create and manage repositories within your Source Code Manager and are able to create and configure the necessary connectors
Prerequisites
-
A new or existing Source Code Manager (SCM) connector with appropriate permissions
Note: The reuse of an existing connector or the Central Build Farm connector is possible as this does not require a dedicated connector. The Connector must live within the scope of either the Account or the Organization. While possible to support a connector at the project level, we advise against it in the event that the connections are required across any of the projects within the Harness Platform Management organization
-
The contents of the Custom Harness Template Library repository pushed into the new repository within your SCM
Note: While not required, we highly advise setting the initial baseline for your custom repository based on the version provided within the Harness Platform Management repository.
-
A delegate with access to your SCM
Note: This is only required for customers hosting their SCM internal to their networks
Modify Standard Variables
- Update the Account-level variable
Custom Template Library Connector
to point to the Connector from which your custom repository will come. The connector should be prefixed withaccount.
ororg.
depending on the scope - Update the Account-level variable
Custom Template Library Repo
to contain the scoped path to your repository based on your connector setup. Note: If you connector points to the root of your SCM, such as https://github.com, then be sure to provide the full repository path excluding the Connector root details.
Creating a new Template
A Terraform scaffold is included within the baseline repository (scaffolds/terraform
). This scaffold includes everything required to begin building out new templates for use with the Solutions Factory.
Learn more about creating new templates
Updating Harness provided samples and baseline templates
Often, the provided samples and baseline templates do not cover 100% of your use cases and require adjustment. In order to customize the Templates, follow the below steps.
-
Clone the Harness Template Library (HTL) repository locally
-
Clone your Custom Template Library (CTL) repository locally
-
Copy the entire template directory from the HTL repository to the root of the CTL repository
-
In your CTL repository, open the directory that you copied to edit the .harness/catalog_template.yaml file
Note: This file contains the details for the IDP workflow and will need to be adjusted for your SCM repository
a. In the yaml, find the property
template_library_connector
and edit the variable. By default, the value should be adjusted from<+variable.account.solutions_factory_template_library_connector>
to<+variable.account.custom_template_library_connector>
b. In the yaml, find the property
template_library_repo
and edit the variable. By default, the value should be adjusted from<+variable.account.solutions_factory_template_library_repo>
to<+variable.account.custom_template_library_repo>
c. STOP If you plan first test the template using a feature branch and not using the
main
branch, then you will need to modify the value for the propertytemplate_library_branch
to point to your specific branch. Note: Make sure to follow the steps in the section titledProduction Readiness
to ensure that all adjustments are ready to be merged into the main branch. -
Optionally, the
metadata.name
can be modified to support registering a new copy without first having to replace the original version. -
Commit and push your changes back to your SCM repository.
Testing and updating IDP with your new workflow
STOP: It is important to note that two templates of the same metadata.name
cannot be registered at the same time to the same IDP environment. To resolve this, you will need to first unregister the current version of workflow within IDP.
This step is only required when under the following conditions
- Replacing the Harness provided version
- Modifying the source repository branch
When replacing or modifying a worklfow branch, you will need to Unregister
the template from your IDP environment. If you modified the metadata.name
to a new value, then skip to Step 8
- Navigate to Internal Developer Portal (IDP) module within your Harness account
- In the left hand navigation, select
Catalog
and change the Kind dropdown toTemplate
- Find the workflow that you need to replace and open the template within IDP. Note: Click the hyperlink for the template name. Do not click the edit buttons
- Click the three dots in the upper right-hand corner
- Choose
Unregister Entity
- In the pop-up window, choose
Unregister Location
- Wait for the unregistration to complete
- In the left hand navigation, select
Register
- Copy the full repository URL to your new
catalog_template.yaml
file. Note:: This should be the entire HTTPS path. - Paste the URL in the field and click Analyze
- Click
Import
. Note: If a matching templatemetadata.name
is registered or the original template had not been removed, the button will sayRefresh
. If this is the case, then STOP and retry the steps fromStep 2
in this list - After the import completes, you can open the link to the
template:<template-name>
provided. - Verify that the
View Source
is pointed to the correct repository and branch. - Click
Launch Template
to test the build
Production Readiness for Custom Templates
STOP: Review the below prior generating a Pull-Request and finalizing your template changes
As part of the testing of the new template, it is entirely likely that you created these changes on a non-default branch. Prior to making the final edits, change any branch
or metadata.name
changes you have made to the template.