From 4cb9e9fdc7ea731d9b169278960fe1db96617bbf Mon Sep 17 00:00:00 2001 From: Sushrut Athavale Date: Wed, 22 May 2024 17:45:39 -0700 Subject: [PATCH] Jenkins trigger prerequisite --- .../docs/spinnaker-migration/prerequisites.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/docs/spinnaker-migration/prerequisites.md b/docs/docs/spinnaker-migration/prerequisites.md index 5169b7b..3ee307f 100644 --- a/docs/docs/spinnaker-migration/prerequisites.md +++ b/docs/docs/spinnaker-migration/prerequisites.md @@ -28,6 +28,36 @@ AWS_SECRET_ACCESS_KEY For information on how to create secrets with Harness, go to [AWS Secrets Manager](https://developer.harness.io/docs/platform/secrets/secrets-management/add-an-aws-secret-manager) +#### Jenkins Trigger + +Unfortunately, Harness does not natively support passing payloads for Jenkins Trigger. Consequently, you cannot use Spinnaker expressions such as `${trigger["properties"]["hash"]}` or `${trigger["properties"]["branch"]}`. + +One possible workaround we suggest is using a custom webhook trigger. For more information about this, go to [Using Custom Triggers](https://developer.harness.io/docs/platform/triggers/trigger-deployments-using-custom-triggers/) + +With this approach, you would need to add a new step to your Jenkins Job, similar to the example below. + +``` +pipeline { + agent any + + stages { + // YOUR STAGES HERE... + + stage('Trigger Harness Pipeline') { + steps { + script { + sh ''' + curl -X POST -H 'Content-Type: application/json' \ + --url 'https://app.harness.io/gateway/pipeline/api/webhook/custom/Wlke4SU6TAeKwDERALcptQ/v3?accountIdentifier=YOUR_ACCOUNT_ID&orgIdentifier=YOUR_ORG_ID&projectIdentifier=YOUR_PROJECT_ID&pipelineIdentifier=YOUR_PIPELINE_ID&triggerIdentifier=webhook_trigger' \ + -d '{"properties": {"hash": "hash_value", "branch": "branch_value"}}' + ''' + } + } + } + } +} +``` + ### GCP Regrettably, Harness lacks native support for triggering pipelines directly via incoming Pub/Sub messages. However, we can work around this limitation by using a custom webhook trigger.