Skip to content

Commit

Permalink
wf settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Dogan committed Feb 18, 2025
1 parent 4dacacf commit 3f9ed9e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ configs:
# workflow
- id: validator-workflow
config:
name: Gitlab Health Validation
name: Demo SRG - Gitlab Pipeline Health Validation
template: gitlab-validator-wf.json
skip: false
parameters:
#wf related
wf_description: "Gitlab Health Validation Workflow that ensures availability and pipeline runs"
wf_description: "Gitlab Pipeline Health Validation Workflow that ensures availability and pipeline runs"
wf_isPrivate: false

gitlab_connection_id:
Expand All @@ -33,4 +33,18 @@ configs:
configId: workflowGitlabConnection
type:
automation:
resource: workflow
resource: workflow

- id: allowOutboundConnections
config:
name: outbound-connections
parameters:
ingress_domain:
type: environment
name: INGRESS_DOMAIN
template: outbound-connections.json
skip: false
type:
settings:
schema: builtin:dt-javascript-runtime.allowed-outbound-connections
scope: environment
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,95 @@
"schemaVersion": 3,
"type": "STANDARD",
"trigger": {
"eventTrigger": {
"schedule": {
"isActive": true,
"filterQuery": "event.type == \"usecase.validation.trigger\"",
"uniqueExpression": null,
"triggerConfiguration": {
"type": "event",
"value": {
"query": "event.type == \"usecase.validation.trigger\"",
"eventType": "bizevents"
}
}
"isFaulty": false,
"trigger": {
"type": "interval",
"intervalMinutes": 240
},
"filterParameters": {
"count": 20
},
"timezone": "Europe/Madrid",
"inputs": {}
}
},
"tasks": {
"get_pipeline_status": {
"name": "get_pipeline_status",
"action": "dynatrace.gitlab.connector:gitlab-get-pipeline-status",
"description": "Get pipeline status using pipeline id from previous action output",
"trigger_pipeline": {
"name": "trigger_pipeline",
"input": {
"branchId": "main",
"projectId": "1",
"connection": "{{ .gitlab_connection_id }}",
"pipelineId": "1"
"variables": [],
"connection": "{{ .gitlab_connection_id }}"
},
"action": "dynatrace.gitlab.connector:gitlab-trigger-pipeline",
"position": {
"x": 0,
"y": 1
},
"description": "Trigger a GitLab pipeline",
"predecessors": []
},
"send_result_bizevent": {
"name": "send_result_bizevent",
"action": "dynatrace.automations:run-javascript",
"description": "Build a custom task running js Code",
"get_pipeline_status": {
"name": "get_pipeline_status",
"input": {
"script": "import { businessEventsClient } from \"@dynatrace-sdk/client-classic-environment-v2\";\n// optional import of sdk modules\nimport { execution } from '@dynatrace-sdk/automation-utils';\n\nexport default async function ({ execution_id }) {\n // your code goes here\n // e.g. get the current execution\n const ex = await execution(execution_id);\n console.log('Automated script execution on behalf of', ex.trigger);\n\n // get the result of task 'my_task'. 'my_task' must be a predecessor.\n var myResult = await ex.result('get_pipeline_status');\n\n // log the result object\n console.log('The whole result object: ', myResult);\n console.log('only one variable: ', myResult.pipeline.status)\n \n const data = await businessEventsClient.ingest({\n type: \"application/cloudevent+json\",\n body: {\n specversion: \"1.0\",\n id: \"1\",\n source: \"custom.source\",\n type: \"usecase.validation.result\",\n component: \"gitlab\",\n result: myResult.pipeline.status,\n dataschema: \"http://dynatrace.com/schema/bizevents/generic/1.0\",\n },\n});\n \n return { triggeredBy: ex.trigger };\n}\n"
"branchId": "main",
"projectId": "1",
"connection": "{{ .gitlab_connection_id }}",
"pipelineId": "{{`{{`}} result(\"trigger_pipeline\").pipeline.id {{`}}`}}"
},
"retry": {
"count": 2,
"delay": 30,
"failedLoopIterationsOnly": true
},
"action": "dynatrace.gitlab.connector:gitlab-get-pipeline-status",
"position": {
"x": 0,
"y": 2
},
"conditions": {
"states": {
"trigger_pipeline": "OK"
}
},
"description": "Get pipeline status using pipeline id from previous action output",
"waitBefore": 1200,
"predecessors": [
"get_pipeline_status"
],
"trigger_pipeline"
]
},
"send_fail_email": {
"name": "send_fail_email",
"input": {
"cc": [],
"to": [
"[email protected]"
],
"bcc": [],
"taskId": "{{ task().id }}",
"content": "Pipeline Failed",
"subject": "Pipeline Failed",
"executionId": "{{ execution().id }}",
"environmentUrl": "{{ environment().url }}"
},
"action": "dynatrace.email:send-email",
"position": {
"x": 0,
"y": 3
},
"conditions": {
"custom": "{{`{{`}} result(\"get_pipeline_status\").pipeline.status != \"success\" {{`}}`}}",
"states": {
"get_pipeline_status": "OK"
}
}
},
"description": "Send email",
"predecessors": [
"get_pipeline_status"
]
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"allowedOutboundConnections": {
"enforced": true,
"hostList": ["*.{{ .ingress_domain }}"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
monaco_manifest_path: "{{ role_path_abs }}/files/health-check/monaco/manifest.yaml"
monaco_environment:
DT_PLATFORM_TENANT_URL: "{{ extra_vars.dt_environment_url_gen3.rstrip('/') }}"
DT_API_TOKEN: "{{ monaco_api_token }}"
INGRESS_DOMAIN: "{{ ingress_domain }}"
DT_OAUTH_CLIENT_ID: "{{ extra_vars.dt_oauth_client_id }}"
DT_OAUTH_CLIENT_SECRET: "{{ extra_vars.dt_oauth_client_secret }}"
DT_OAUTH_SSO_ENDPOINT: "{{ extra_vars.dt_oauth_sso_endpoint }}"
Expand Down

0 comments on commit 3f9ed9e

Please sign in to comment.