forked from akirasoft1/dynatrace-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
out
executable file
·41 lines (27 loc) · 1.35 KB
/
out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -e
cd "${1}"
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
PATH=/usr/local/bin:$PATH
PAYLOAD=$(mktemp /tmp/resource-in.XXXXXX)
cat > "$PAYLOAD" <&0
#values from credentials file
apitoken="$(jq -r '.source.apitoken' < "${PAYLOAD}")"
tenanthost="$(jq -r '.source.tenanthost' < "${PAYLOAD}")"
#values from pipeline
monspecserviceenvironment="$(jq -r '.params.monspecserviceenvironment' < "${PAYLOAD}")"
pipelinetaskname="$(jq -r '.params.pipelinetaskname' < "${PAYLOAD}")"
deployversion="$(jq -r '.params.deployversion' < "${PAYLOAD}")"
APP_REPO="$(jq -r '.params.APP_REPO' < "${PAYLOAD}")"
echo "configuring Dynatrace CLI with $apitoken and $tenanthost"
python /dtcli/dtcli.py config apitoken $apitoken tenanthost $tenanthost debug 1
echo "pushing Deployment version $deployversion to service $monspecserviceenvironment defined in $APP_REPO via task $pipelinetaskname"
# #debug
# ls -la ./$APP_REPO/
# ls -la ./$APP_REPO/ci/smplmonspec.json
# ls -la ./$APP_REPO/ci/smplpipelineinfo.json
#desired:
python /dtcli/dtcli.py monspec pushdeploy ./$APP_REPO/ci/smplmonspec.json ./$APP_REPO/ci/smplpipelineinfo.json $monspecserviceenvironment $pipelinetaskname $deployversion
timestamp="$(jq -n "{version:{timestamp:\"$(date +%s)\"}}")"
echo "$timestamp $metadata $debug_info " | jq -s add >&3