Introduction
With Harness In addition to Triggers using Git providers, artifact providers, manifests, and cron scheduling, Harness includes Custom Triggers that you can use to run Pipelines via a platform-agnostic Webhook.
In this blog we will see how we can pass a input variable (note we will be passing custom variable declared as part of the pipeline not pipeline variables) to a pipeline with custom trigger curl command.
something like this
curl -X POST -H 'content-type: application/json' --url 'https://app.harness.io/gateway/pipeline/api/webhook/custom/v2?accountIdentifier=&orgIdentifier=default&projectIdentifier=CD_Docs&pipelineIdentifier=Triggers&triggerIdentifier=Custom' -d '{"sample_key": "sample_value"}'
Here instead of {“sample_key”: “sample_key”} we can pass custom variable which we declare as part of the pipeline like atrtifact tag {“tag”: “stable-perl”} which can be provided as a runtime input in the pipeline.
Let’s see this working in the pipeline
Step 1 : Declare the variable as part of the pipeline, we will passing image tag : satble-perl in the curl trigger command therefor let’s declare a variable with relevant name as tag and value as <+trigger.payload.tag.toLowerCase()>
Step 2 : We can pass this declared variable as a runtime input with curl command
Step 3 : Finally let’s pass the image tag in the curl command as below
curl -X POST -H 'content-type: application/json' --url 'https://app.harness.io/gateway/pipeline/api/webhook/custom/v2?accountIdentifier=&orgIdentifier=default&projectIdentifier=CD_Docs&pipelineIdentifier=Triggers&triggerIdentifier=Custom' -d '{"tag": "stable-perl"}'
Happy Building Deploying and much more with Harness