May 6, 2024

Integrating third party tools with Harness Deployment pipelines for improved efficiency

Table of Contents

Harness Deployment Pipelines allow seamless integration with third-party tools, enhancing testing, performance, and security. This integration uses API and webhook methods, enabling automated, efficient commit-to-deploy processes. By configuring dynamic triggers and external approvals, teams can achieve improved software delivery efficiency.

Overview

In this blog, let's get a brief idea of how to achieve the integration of 3rd-party tools with Harness CD pipelines to accomplish commit-to-deploy scenarios.

Harness enables faster, seamless code deployment into target systems as part of product development. This can be achieved by configuring the target deployments using pipeline CD functions. However, it must undergo rigorous testing to strengthen and ensure stable code reaches production. Several third-party tools are available in the market to help ensure high-quality code before production deployment. Harness CD supports the integration of third-party tools to leverage and strengthen testing, performance, and security, thereby achieving an end-to-end process using Harness pipelines and third-party tools.

How are pipelines designed to ensure production-ready code reaches?

Deployment pipelines are designed with different stages, for each of the environments where the deployment is carried out. Once the code is built and available for deployment, triggers are used to execute the deployment once the artifacts are available. Pipeline stages corresponding to the target environment are triggered based on the need. For example, when the code is ready for internal testing, it is deployed only to QA targets. During the continuous integration process, it is deployed only to the Dev stage, and the other stages are skipped from execution. Pipelines natively support selective stage execution, as described here, and conditional execution, as described here.

Approvals are natively designed in each of the stages to ensure the required conditions are met and approved by super users before deployment. 

What are the scenarios and what kind of tools can be integrated?


When testing is bolstered using external 3rd-party tools, it becomes necessary to integrate these tools and synchronize their execution with the deployment process. This integration is facilitated through the touchpoints of selective stages and approvals.

Integration is achieved through API-based and webhook-based methods.3rd party tools can register and achieve integration using the above methods.

Example scenarios where the above integrations are utilized to achieve end-to-end automation include:

  1. The testing tool completes the tests, and upon successful results, triggers the execution of the deployment pipeline.
  2. The pipeline is executed, and all necessary approvals required in the stage of the pipeline are initiated from the external 3rd party system.

How is this achieved in pipelines in an automated fashion?

This is accomplished using Dynamic Triggers and External Approval concepts supported by Harness pipelines and triggers.

Scenario one requires dynamic inputs of stage and input set to be provided by the testing tool. Harness triggers now support dynamic input sets and stages, which can be provided as inputs. The test system provides these inputs using a simple trigger definition and execution as follows:

Trigger configuration supports expression configuration for input sets and stages as in the below example.

Below is the sample Harness custom trigger yaml:

trigger:
name: <val>
identifier: <val>
enabled: true
description: ""
tags: {}
stagesToExecute: <+trigger.payload.stage>
orgIdentifier: <val>
projectIdentifier: <val>
pipelineIdentifier: <val>
source:
  type: Webhook
  spec:
    type: Custom
    spec:
      payloadConditions: []
      headerConditions: []
inputSetRefs: <+trigger.payload.inputset>

curl -X POST -H 'content-type: application/json' --url '<baseurl>&triggerIdentifier=dd' -d '{"inputset": "inputset1" ,"stage":"stageval"}'

Third-party tools register the above webhook and execute the pipeline when the test completion event is available at the tool.

How are approvals achieved from any third-party tools without any dependencies?

API-based integration facilitates easy and loose coupling between 3rd-party tools and Harness pipelines. Approval APIs enable seamless integration, whereas 3rd-party tools such as Vulcan, Sonar, or Checkmarx call the approval APIs after the tests are completed. Approval is integrated into the deployment process within the stage, allowing 3rd-party tools not only to trigger the pipeline but also to perform approval using the APIs exposed for Harness approval.

 Approval API can be referred here.

Third-party tools can easily provide the approval using the approval unique id . Each Harness approval step provides a mechanism of assigning a user-friendly identifier in the step configuration. This id can be fixed henceforth in the 3rd party tool which requires to provide approval and proceeding with the deployment.

Configuring a unique id for Harness approval and seamlessly approving from external sources.

Below is the sample yaml for setting up Harness Approval pipeline:

pipeline:
  projectIdentifier: <val>
  orgIdentifier: default
  tags: {}
  stages:
    - stage:
        name: approval
        identifier: approval
        description: ""
        type: Approval
        spec:
          execution:
            steps:
              - step:
                  name: approval
                  identifier: approval
                  type: HarnessApproval
                  timeout: 1d
                  spec:
                    approvalMessage: |-
                      Please review the following information
                      and approve the pipeline progression
                    includePipelineExecutionHistory: true
                    approvers:
                      minimumCount: 1
                      disallowPipelineExecutor: false
                      userGroups:
                        - <+input>
                    isAutoRejectEnabled: false
                    approverInputs: []
        tags: {}
  identifier: <val>
  name: <val>
  allowStageExecutions: true

Conclusion

Support for integration of 3rd party tools with Harness CD pipelines helps businesses improve abilities and improves efficiency.

Support for these integration touchpoints enables different heterogeneous tools to asynchronously communicate with each other and achieve commit to deploy in an automated fashion

Further learning

Read more about using Harness Approval as well as Harness Approval APIs.

Read more about Selective stage execution dynamically in Harness.

Platform