API Triggers: Dynamic List of Artifact Deployments

Hey all!

One of the things that I hear often is whether or not Harness has the ability to take an input which declares a dynamic set of services to be deployed (Example: I have 10 potential services and want to deploy any combination or count of those 10 services via a Trigger).

Although Harness does not have a way to take in a document (XML, JSON, YAML, etc.) and parse that for the dynamic execution type, I recently created a script that allowed a customer to do that.

Harness Setup
The first thing you will need is the Artifacts/Services set-up in Harness with the appropriate Environment and Service Infrastructure assigned to it (Make sure that the Service Infrastructure has an easy to use name).

SERVICES:



ENVIRONMENT/SERVICE INFRASTRUCTURE

Then you’ll need to create a Workflow (Rolling or Blue/Green) and then when you edit it, select the triple-dots on the right side of the overview to “Edit”

You’ll then want to click all of the image and turn them into image. This will allow you to templatize the workflow so that you can require those values in the Trigger to execute this Workflow.

The next thing you will need to do is create a Trigger to execute the Workflow with the following custom variables in the trigger (This will allow you to pass variables to the Workflow):

After this is done, you’ll need to grab the API cURL command

Script

Here is the Git Repo with the appropriate script

This will then run the templatized workflow twice with the designated options.

Don’t forget to Comment/Like/Share!

2 Likes