• Home
  • How to use Dynatrace
  • Cloud Automation
  • Partner integrations
  • JFrog integration

JFrog integration

Integrating Dynatrace Cloud Automation with JFrog enables software engineering and operations teams to include pipeline runs in Cloud Automation sequences. This saves engineers time and increases confidence by providing both automated data-driven release decisions and problem remediation.

To integrate Dynatrace Cloud Automation with JFrog, follow the instructions below.

Prerequisites

JFrog

Dynatrace

JFrog

  • JFrog free SaaS DevOps subscription with JFrog Pipelines activated

  • Create a JFrog Pipelines incoming webhook that will be used by Cloud Automation to trigger a pipeline build

    How to create an incoming webhook
    1. Log in to your Jfrog account (for example, https://xxx123.jfrog.io/).

    2. Go to the Administration tab > Pipelines > Integrations.

    3. Select Add an integration and enter the following values:

      • Name: Enter a webhook name, for example, IncomingWehookIntegration.
      • Integration type: Select Incoming webhook.
      • Authorization type: Enter your preferred authorization type.
  • Add a JFrog Pipelines Generic Integration to create a secret for your Cloud Automation API token and URL.

    How to create a generic integration
    1. Log in to your Jfrog account (for example, https://xxx123.jfrog.io/).

    2. Go to the Administration tab > Pipelines > Integrations.

    3. Select Add an integration and enter the following values:

      • Name: Enter an integration name, such as cloudAutomation. You will be able to access the secret securely in your pipeline.yml file using the int_cloudAutomationCred_<key> environment variable.
      • Integration type: Select Generic integration.
    4. Add the following key/value pairs:

      • Key: KEPTN_BASE_URL; Value: Your base Cloud Automation URL (for example, https://xxx12345.cloudautomation.live.dynatrace.com)
      • Key: KEPTN_API_TOKEN; Value: The Cloud Automation API token from your Cloud Automation bridge.

Dynatrace

  • Create a Cloud Automation project with a shipyard file that has a custom task (for example, release) to trigger the JFrog webhook subscription.

  • Add the JFrog incoming webhook URL obtained above as a Cloud Automation secret.

    How to add the API key as a Cloud Automation secret
    1. On the Cloud Automation bridge, select your Cloud Automation project.

    2. Select Settings, and then select Secrets.

    3. Select Add Secret and enter the following values:

      • Name: Enter a name for the secret (for example, jfrog).
      • Scope: Select keptn-webhook-service.
    4. Add a Key/Value pair with the following values:

      • Key: Enter any value, for example WEBHOOKAUTH
      • Value: Enter a username:password combination. For example, if your username is user123i and your password is password123i, the secret value would be user123i:password123i.
    5. Select Add secret.

Set up the JFrog webhook subscription

Use case: Run a performance test or deploy code as part of a Cloud Automation sequence.

In JFrog

  1. Adjust your JFrog pipeline to

    • Start when the incoming webhook is triggered
    • Send back a Cloud Automation finished event

    The custom payload with the metadata configured can be accessed using an automatically built environment variable.

    These items are part of the incoming webhook’s payload as sent by Cloud Automation:

    • project
    • stage
    • service
    • shkeptncontext
    • id
  2. After the pipeline build is finished, JFrog notifies Cloud Automation so that the sequence can continue with the following JSON object:

    json
    { "data":{ "project":"{PROJECT}", "stage":"{STAGE}", "service":"{SERVICE}", "status":"succeeded", "result":"pass" }, "source":"jfrog ", "specversion":"1.0", "type":"sh.keptn.event.{TASK NAME}.finished", "shkeptncontext":"{SHKEPTNCONTEXT}", "triggeredid":"{ID}" }

Example

Below is a complete example that assumes

  • A JFrog webhook integration called IncomingWebhookIntegration
  • A JFrog generic integration called cloudAutomationCred with the Cloud Automation URL and API Token
  • A Cloud Automation sequence task called release that triggered this JFrog incoming webhook

Integrate the following code example into your existing pipeline definition:

yaml
resources: - name: incoming_webhook type: IncomingWebhook configuration: webhookName: IncomingWebhookIntegration pipelines: - name: release_demo_pipeline steps: - name: Processing_Incoming_Webhook type: Bash configuration: affinityGroup: Cloud_Automation_Webhook inputResources: - name: incoming_webhook execution: onExecute: - echo "$res_incoming_webhook_payload" | jq '.' > payload.json - project=$(read_json payload.json "project") - stage=$(read_json payload.json "stage") - service=$(read_json payload.json "service") - id=$(read_json payload.json "id") - shkeptncontext=$(read_json payload.json "shkeptncontext") - jfrogUrl=$(echo $step_url | cut -d? -f1) - | add_run_variables event_payload="$(cat <<-END { "data": { "project": "$project", "stage": "$stage", "service": "$service", "status": "succeeded", "result": "pass", "release": { "jfrogUrl": "$jfrogUrl" }, "labels": { "jfrogUrl": "$jfrogUrl" } }, "source": "jfrog-pipeline", "specversion": "1.0", "type": "sh.keptn.event.release.finished", "shkeptncontext": "$shkeptncontext", "triggeredid": "$id" } END )" - name: Send_Finish_Event type: Bash configuration: affinityGroup: Cloud_Automation_Webhook integrations: - name: cloudAutomationCred inputSteps: - name: Processing_Incoming_Webhook execution: onExecute: - 'curl -X POST "$int_cloudAutomationCred_KEPTN_BASE_URL/api/v1/event" -H "accept: application/json" -H "x-token: $int_cloudAutomationCred_KEPTN_API_TOKEN" -H "Content-Type: application/json" -d "$event_payload"'

On the Cloud Automation bridge

  1. Select your Cloud Automation project.

  2. Select Settings, and then select Integrations.

  3. Select webhook-service from the list, and then select Add subscription.

  4. Enter the following values:

    • Task: Select a task (for example, release).

    • Task suffix: Select triggered.

    • Request method: Select POST.

    • URL: Enter the incoming webhook URL concatenated with the secret you created in Prerequisites.

      Example: If a webhook is https://user123i:Password123@myproject-pipelines-api.jfrog.io/v1/projectIntegrations/9/hook and your secret's name is WEBHOOKAUTH, the URL value should be https://{{.secret.jfrog.WEBHOOKAUTH}}@api.jfrog.io/v1/projectIntegrations/9/hook.

  5. Select Add custom header and enter the following values:

    • For Name, enter Content-Type
    • For Value, enter application/JSON
  6. Enter a Custom payload.

    Example:

    json
    { "type": "{{.type}}", "project": "{{.data.project}}", "service": "{{.data.service}}", "stage": "{{.data.stage}}", "shkeptncontext": "{{.shkeptncontext}}", "id": "{{.id}}" }
  7. Under Send started event, select automatically.

  8. Under Send finished event, select by webhook receiver.

  9. Select Create subscription.

Trigger a sequence

Cloud Automation triggers the JFrog pipeline whenever the defined task in the sequence is triggered.

To trigger the sequence, follow the steps below.

  1. Create a file named triggered-event.json.

    Example:

    json
    { "type": "sh.keptn.event.mystage.release.triggered", "specversion":"1.0", "source":"manual-trigger" "data":{ "project":"myproject", "stage":"mystage", "service":"myservice" } }
  2. Send the event.

    bash
    keptn send event --file triggered-event.json

After sending the event, you can

  • Monitor the sequence progress on the Cloud Automation sequence page of the project
  • Monitor the JFrog pipeline progress on the JFrog Web UI
Related topics
  • Cloud Automation

    The capabilities of Dynatrace Cloud Automation