-
Notifications
You must be signed in to change notification settings - Fork 1
/
out
executable file
·49 lines (33 loc) · 1.56 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
42
43
44
45
46
47
48
49
#!/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
# do stuff
#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}")"
APP_REPO="$(jq -r '.params.APP_REPO' < "${PAYLOAD}")"
deployversion="$(jq -r '.params.deployversion' < "${PAYLOAD}")"
VERSION_FILE="$(jq -r '.params.VERSION_FILE' < "${PAYLOAD}")"
# jq statements above set missing values to the actual string null
if [ "$VERSION_FILE" != "null" ]; then
echo "using version from file"
export version=$(cat ./$VERSION_FILE)
else
echo "using hardcoded version from pipeline"
export version=$deployversion
fi
echo "configuring Dynatrace CLI with $apitoken and $tenanthost"
python /dtcli/dtcli.py config apitoken $apitoken tenanthost $tenanthost
#debug 1
echo "pushing Deployment version $version to service $monspecserviceenvironment defined in $APP_REPO via task $pipelinetaskname"
python /dtcli/dtcli.py monspec pushdeploy ./$APP_REPO/ci/smplmonspec.json ./$APP_REPO/ci/smplpipelineinfo.json $monspecserviceenvironment $pipelinetaskname $version
timestamp="$(jq -n "{version:{timestamp:\"$(date +%s)\"}}")"
echo "$timestamp $metadata $debug_info " | jq -s add >&3