Integrate JFrog with Dynatrace Cloud Automation
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
-
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
-
Log in to your Jfrog account (for example,
https://xxx123.jfrog.io/
). -
Go to the Administration tab > Pipelines > Integrations.
-
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.
- Name: Enter a webhook name, for example,
-
-
Add a JFrog Pipelines Generic Integration to create a secret for your Cloud Automation API token and URL.
-
Log in to your Jfrog account (for example,
https://xxx123.jfrog.io/
). -
Go to the Administration tab > Pipelines > Integrations.
-
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 yourpipeline.yml
file using theint_cloudAutomationCred_<key>
environment variable. - Integration type: Select
Generic integration
.
- Name: Enter an integration name, such as
-
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.
- Key:
-
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.
-
On the Cloud Automation bridge, select your Cloud Automation project.
-
Select Settings, and then select Secrets.
-
Select Add Secret and enter the following values:
- Name: Enter a name for the secret (for example,
jfrog
). - Scope: Select
keptn-webhook-service
.
- Name: Enter a name for the secret (for example,
-
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 isuser123i
and your password ispassword123i
, the secret value would beuser123i:password123i
.
- Key: Enter any value, for example
-
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
-
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
-
After the pipeline build is finished, JFrog notifies Cloud Automation so that the sequence can continue with the following JSON object:
1{2 "data":{3 "project":"{PROJECT}",4 "stage":"{STAGE}",5 "service":"{SERVICE}",6 "status":"succeeded",7 "result":"pass"8 },9 "source":"jfrog ",10 "specversion":"1.0",11 "type":"sh.keptn.event.{TASK NAME}.finished",12 "shkeptncontext":"{SHKEPTNCONTEXT}",13 "triggeredid":"{ID}"14}
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:
1resources:2 - name: incoming_webhook3 type: IncomingWebhook4 configuration:5 webhookName: IncomingWebhookIntegration67pipelines:8 - name: release_demo_pipeline9 steps:10 - name: Processing_Incoming_Webhook11 type: Bash12 configuration:13 affinityGroup: Cloud_Automation_Webhook14 inputResources:15 - name: incoming_webhook16 execution:17 onExecute:18 - echo "$res_incoming_webhook_payload" | jq '.' > payload.json19 - project=$(read_json payload.json "project")20 - stage=$(read_json payload.json "stage")21 - service=$(read_json payload.json "service")22 - id=$(read_json payload.json "id")23 - shkeptncontext=$(read_json payload.json "shkeptncontext")24 - jfrogUrl=$(echo $step_url | cut -d? -f1)25 - |26 add_run_variables event_payload="$(cat <<-END27 {28 "data": {29 "project": "$project",30 "stage": "$stage",31 "service": "$service",32 "status": "succeeded",33 "result": "pass",34 "release": {35 "jfrogUrl": "$jfrogUrl"36 },37 "labels": {38 "jfrogUrl": "$jfrogUrl"39 }40 },41 "source": "jfrog-pipeline",42 "specversion": "1.0",43 "type": "sh.keptn.event.release.finished",44 "shkeptncontext": "$shkeptncontext",45 "triggeredid": "$id"46 }47 END48 )"49 - name: Send_Finish_Event50 type: Bash51 configuration:52 affinityGroup: Cloud_Automation_Webhook53 integrations:54 - name: cloudAutomationCred55 inputSteps:56 - name: Processing_Incoming_Webhook57 execution:58 onExecute:59 - '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
-
Select your Cloud Automation project.
-
Select Settings, and then select Integrations.
-
Select webhook-service from the list, and then select Add subscription.
-
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 isWEBHOOKAUTH
, the URL value should behttps://{{.secret.jfrog.WEBHOOKAUTH}}@api.jfrog.io/v1/projectIntegrations/9/hook
.
-
-
Select Add custom header and enter the following values:
- For Name, enter
Content-Type
- For Value, enter
application/JSON
- For Name, enter
-
Enter a Custom payload.
Example:
1{2 "type": "{{.type}}",3 "project": "{{.data.project}}",4 "service": "{{.data.service}}",5 "stage": "{{.data.stage}}",6 "shkeptncontext": "{{.shkeptncontext}}",7 "id": "{{.id}}"8} -
Under Send started event, select
automatically
. -
Under Send finished event, select
by webhook receiver
. -
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.
-
Create a file named
triggered-event.json
.Example:
1{2 "type": "sh.keptn.event.mystage.release.triggered",3 "specversion":"1.0",4 "source":"manual-trigger"5 "data":{6 "project":"myproject",7 "stage":"mystage",8 "service":"myservice"9 }10} -
Send the event.
1keptn 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