-
Notifications
You must be signed in to change notification settings - Fork 14
/
umb-build-message.sh
executable file
·68 lines (56 loc) · 1.8 KB
/
umb-build-message.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
readonly REQUIRED_VARS=(SERVER_URL BUILD_ID BUILD_URL SCM_URL SCM_REVISION RELEASE_NAME RELEASE_STREAM RELEASE_TYPE VERSION BASE_VERSION)
if ! command -v jq &> /dev/null
then
echo "jq could not be found"
exit 1
fi
MISSING_VARS=""
for var in "${REQUIRED_VARS[@]}"
do
if [ -z "${!var}" ]; then
if [ -n "${MISSING_VARS}" ]; then
MISSING_VARS="${MISSING_VARS} ${var}"
else
MISSING_VARS="${var}"
fi
fi
done
if [ -n "${MISSING_VARS}" ]; then
echo "Required properties are not found: ${MISSING_VARS}"
exit 2
fi
server=$( jq -n '{ server: $ARGS.named }' \
--arg url "${SERVER_URL}" \
--arg build-type "jenkins" \
--arg build-id "${BUILD_ID}" \
--arg build-url "${BUILD_URL}" \
--arg scm-type: "git" \
--arg scm-url: "${SCM_URL}" \
--arg scm-revision: "${SCM_REVISION}" )
sources=$( jq -n '{ "server-name": $ARGS.named }' \
--arg url "${SOURCE_URL}" \
--arg build-type "jenkins" \
--arg build-id "${BUILD_ID}" \
--arg build-url "${BUILD_URL}" \
--arg scm-type: "git" \
--arg scm-url: "${SCM_URL}" \
--arg scm-revision: "${SCM_REVISION}" )
server=$( echo "${server}" | jq '.server' )
sources=$( echo "${sources}" | jq '."server-name"' )
bits=$( jq -n '{bits: $ARGS.named}' \
--argjson server "$server" --argjson server-sources "$sources" )
bits=$( echo "${bits}" | jq '.bits' )
msg=$( jq -n '{release: $ARGS.named}' \
--arg name "$RELEASE_NAME" \
--arg stream "$RELEASE_STREAM" \
--arg type "$RELEASE_TYPE" \
--arg version "$VERSION" \
--arg target-version "$BASE_VERSION" \
--arg eap-base-version "$BASE_VERSION" \
--arg url "$BUILD_URL" \
--argjson bits "$bits" )
echo "${msg}" | jq > message_body.json
EOL=$'\n'
echo "MESSAGE_CONTENT=${msg//$EOL/}" >> MESSAGE.txt
cat message_body.json