Trigger a Deployment using cURL

Updated 1 month ago by Michael Cretzman

For Build Workflows or a  Build and Deploy Pipeline, you can trigger deployments in response to a Git event using Webhooks. This is described in Trigger Deployments using Git Events.

Once you have created a Harness On Webhook Event Trigger, Harness creates a Manual Trigger for it.

You can do the following with a Manual Trigger:

This topic describes how to obtain and use the cURL command.

This option is used to execute a Build Workflow or a Build Pipeline only.

In this topic:

Before You Begin


In the Actions section of the Trigger, the Deploy only if files have changed option is available for Workflows deploying Kubernetes or Native Helm Services only.

Step 1: Create the Git Webhook Trigger

Follow the steps in Trigger Deployments using Git Events.

When you are finished, the Trigger is displayed in the Triggers list, and includes a Manual Trigger option.

Step 2: Get and Run the cURL Command

Click Manual Trigger.

In the Manual Trigger, click Show Curl Command.

The curl command is displayed. It will look something like the this (private information has been replaced with xxxxxx):

curl -X POST -H 'content-type: application/json' \
--url \
-d '{"application":"xxxxxx","artifacts":[{"service":"micro-service","buildNumber":"micro-service_BUILD_NUMBER_PLACE_HOLDER"}]}'

Copy the curl command, replace the placeholders with actual values, and run it in a terminal.

Review: Placeholders and Manual Settings

When you created a Trigger, if you selected values for parameters that are represented by placeholders in the cURL command, you do not need to add values for the cURL placeholders.

If you add values for the cURL placeholders, you will override manual settings in the Trigger.

This is also true for Triggers that execute templated Workflows and Pipelines. If you create a Trigger that executes a templated Workflow or Pipeline, you can select values for the templated settings in the Trigger, but you can still override them in the cURL command.

Let's look at a placeholder example:

curl -X POST -H 'content-type: application/json' \
--url \
-d '{"application":"xxxxxx","artifacts":[{"service":"micro-service","buildNumber":"micro-service_BUILD_NUMBER_PLACE_HOLDER"}]}'

For service, enter the name of the Harness Service.

For buildNumber, enter the artifact build number from the Artifact History in the Service.

For example:

curl -X POST -H 'content-type: application/json' \
--url \
-d '{"application":"xxxxxx","artifacts":[{"service":"Service-Example","buildNumber":"1.17.8-perl"}]}'

The output will be something like this (private information has been replaced with xxxxxx):


The uiUrl can be used directly in a browser.

See Trigger a Deployment using a URL.

apiUrl can be used to track deployment status programmatically, such as using a REST call.

See Get Deployment Status using REST.

Placeholders and Workflow Variables

In the cURL command, placeholder values are added for any Workflow variables rather than the variables selected when creating the Trigger.

The placeholder values added to the cURL command override any existing values, including Workflow variables selected in the Trigger.

You can choose to ignore the placeholders and not pass values for any variables in the cURL command.

Configure As Code

To see how to configure the settings in this topic using YAML, configure the settings in the UI first, and then click the YAML editor button (</>).

How did we do?