forked from mattermost/mattermost-integration-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 43
/
entrypoint.sh
executable file
·54 lines (42 loc) · 1.36 KB
/
entrypoint.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
#!/bin/bash
PLUGIN_ARGS=
if [ -n "${MATTERMOST_USERNAME}" ]; then
PLUGIN_ARGS="${PLUGIN_ARGS} --username ${MATTERMOST_USERNAME}"
fi
if [ -n "${MATTERMOST_CHANNEL}" ]; then
PLUGIN_ARGS="${PLUGIN_ARGS} --channel ${MATTERMOST_CHANNEL}"
fi
if [ -n "${MATTERMOST_ICON}" ]; then
PLUGIN_ARGS="${PLUGIN_ARGS} --icon ${MATTERMOST_ICON}"
fi
EVENTS=( PUSH TAG )
for POSSIBLE_EVENT in "${EVENTS[@]}"; do
ENV_NAME="MATTERMOST_EVENT_${POSSIBLE_EVENT}"
eval VALUE=\$${ENV_NAME}
if [ -n "${VALUE}" ]; then
if [ "${VALUE}" == "1" -o "${VALUE}" == "yes" -o "${VALUE}" == "y" ]; then
PLUGIN_ARGS="${PLUGIN_ARGS} --${POSSIBLE_EVENT,,}"
fi
fi
done
NEGATIVE_EVENTS=( ISSUE COMMENT MERGE-REQUEST CI )
for POSSIBLE_EVENT in "${NEGATIVE_EVENTS[@]}"; do
ENV_NAME="MATTERMOST_EVENT_${POSSIBLE_EVENT}"
eval VALUE=\$${ENV_NAME}
if [ -n "${VALUE}" ]; then
if [ "${VALUE}" == "0" -o "${VALUE}" == "n" -o "${VALUE}" == "no" ]; then
PLUGIN_ARGS="${PLUGIN_ARGS} --no-${POSSIBLE_EVENT,,}"
fi
fi
done
if [ -z "${MATTERMOST_WEBHOOK_URL}" ]; then
echo "Missing Mattermost WEBHOOK url !" >&2
exit 1
fi
if [ ! -x "/usr/local/bin/mattermost_gitlab" ]; then
echo "Missing application executable !" >&2
exit 1
fi
echo "Starting: "
echo "/usr/local/bin/mattermost_gitlab ${PLUGIN_ARGS} '${MATTERMOST_WEBHOOK_URL}'"
/usr/local/bin/mattermost_gitlab ${PLUGIN_ARGS} "${MATTERMOST_WEBHOOK_URL}"