Skip to content

Commit

Permalink
srg script
Browse files Browse the repository at this point in the history
  • Loading branch information
eemrdog committed Jan 19, 2024
1 parent 3c0e5b7 commit ef5ef31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ pipeline {
// DT params
DT_API_TOKEN = credentials('DT_API_TOKEN')
DT_TENANT_URL = credentials('DT_TENANT_URL')
DYNATRACE_URL_GEN3 = "${env.DYNATRACE_URL_GEN3}"
ACCOUNT_URN = credentials('ACCOUNT_URN')
DYNATRACE_CLIENT_ID = credentials('DYNATRACE_CLIENT_ID')
DYNATRACE_SECRET = credentials('DYNATRACE_SECRET')
DYNATRACE_SSO_URL = credentials('DYNATRACE_SSO_URL')
SRG_EVALUATION_SERVICE = 'simplenodeservice'
SRG_EVALUATION_STAGE = 'staging'

}
agent {
Expand Down Expand Up @@ -126,21 +133,19 @@ pipeline {
agent {
label 'dta-runner'
}

steps {
unstash 'srg.test.starttime'
unstash 'srg.test.endtime'

container('dta-runner') {
sh """
export SRG_EVALUATION_SERVICE: "$RELEASE_PRODUCT"
export SRG_EVALUATION_STAGE: "staging"

echo "BUILD_ID $BUILD_ID is being evaluated via Site Reliability Guardian"
eval_start="${cat srg.test.starttime}"
eval_end="${cat srg.test.endtime}"
export LOG_LEVEL=verbose
dta srg evaluate --service $SRG_EVALUATION_SERVICE --stage $SRG_EVALUATION_STAGE --start-time=$eval_start --end-time=$eval_end --stop-on-failure
"""
container('dta') {
script {
sh """
eval_start=\$(cat srg.test.starttime)
eval_end=\$(cat srg.test.endtime)
dta srg evaluate --service $SRG_EVALUATION_SERVICE --stage $SRG_EVALUATION_STAGE --start-time=\$eval_start --end-time=\$eval_end --stop-on-failure
"""
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,69 +40,6 @@
"y": 1
},
"predecessors": []
},
"query_service_entities": {
"name": "query_service_entities",
"input": {
"query": "{{ .dql_service_entities_query }}"
},
"action": "dynatrace.automations:execute-dql-query",
"position": {
"x": 0,
"y": 2
},
"conditions": {
"custom": "{{ `{{` }} result(\"evaluate_srg\").validation_status != \"pass\" {{ `}}` }}",
"states": {
"evaluate_srg": "OK"
}
},
"description": "Executes DQL query",
"predecessors": ["evaluate_srg"]
},
"identify_ownership": {
"name": "identify_ownership",
"input": {
"entityIds": "{{ `{{` }} result(\"query_service_entities\").records[0].id {{ `}}` }}",
"responsibilities": []
},
"action": "dynatrace.ownership:get-ownership-from-entity",
"position": {
"x": 0,
"y": 3
},
"conditions": {
"states": {
"query_service_entities": "SUCCESS"
}
},
"description": "Retrieves entity and extracts ownership data from it.",
"predecessors": ["query_service_entities"]
},
"create_gitea_issue": {
"action": "dynatrace.automations:http-function",
"conditions": {
"custom": "{{`{{`}} (result('identify_ownership').owners | length > 0) {{`}}`}}",
"states": {
"identify_ownership": "OK"
}
},
"description": "{{ .gitea_task_description }}",
"input": {
"headers": {
"Content-Type": "application/json",
"PRIVATE-TOKEN": "{{ .gitea_private_token }}"
},
"method": "POST",
"url": "{{ .gitea_url }}/api/v4/projects/{{`{{`}} result(\"identify_ownership\").owners[0].contactDetails | selectattr('integrationType', 'equalto', 'JIRA') | map(attribute='jira.project') | first() {{`}}`}}/issues",
"payload": "{\n \"title\": \"Site Reliability Guardian validation failed\",\n \"description\": \"For the SRG validation details, go to {{`{{`}} result(\"evaluate_srg\").validation_url {{`}}`}}\"\n}"
},
"name": "create_gitea_issue",
"position": {
"x": 0,
"y": 4
},
"predecessors": ["identify_ownership"]
}
}
}

0 comments on commit ef5ef31

Please sign in to comment.