@@ -74,37 +74,37 @@ if [ ! -e "$datahub_secrets" ]; then
74
74
exit 1
75
75
fi
76
76
77
- . " $datahub_secrets "
78
-
79
- # setup logging
80
- declare -rg log_file=" /var/log/datahub/${0##*/ } .$$ .log"
81
- if [ " $HOOK_DEBUG " = " 1" ]; then
82
- exec & > " $log_file "
83
- set -x
84
- fi
85
-
86
77
# Get the event from stdin
87
78
json=" $( cat -) "
88
- echo " EVENT: $( jq . <<< " $json" ) "
89
79
90
80
event_type=" $( jq -r ' .object_kind // empty' <<< " $json" ) "
91
81
event_name=" $( jq -r ' .event_name // empty' <<< " $json" ) "
92
82
event_ref=" $( jq -r ' .object_attributes.ref // empty' <<< " $json" ) "
93
83
event_id=" $( jq -r ' .object_attributes.id // empty' <<< " $json" ) "
94
84
95
- if { [ -n " $event_type " ] && [ " $event_type " != " pipeline" ] && [ " $event_type " != " push" ]; } \
96
- || { [ -n " $event_name " ] && [ " $event_name " != " project_create" ] ; } \
97
- || { [ -n " $event_name " ] && [ " $event_name " != " push" ] ; }; then
85
+ if { [ -n " $event_type " ] && [ " $event_type " != " pipeline" ]; } \
86
+ || { [ -n " $event_name " ] && [ " $event_name " != " project_create" ] && [ " $event_name " != " push" ]; }; then
98
87
echo " Ignoring $event_type | $event_name "
99
88
exit 0
100
89
fi
101
90
102
- # for event_types the project id is in .project.id
91
+ # # Read the configuration file
92
+ . " $datahub_secrets "
93
+
94
+ # setup logging
95
+ declare -rg log_file=" /var/log/datahub/${0##*/ } .$$ .log"
96
+ if [ " $HOOK_DEBUG " = " 1" ]; then
97
+ exec & > " $log_file "
98
+ set -x
99
+ fi
100
+
103
101
project_id=" $( jq -r ' .project.id // empty' <<< " $json" ) "
104
- # for event_name the project id is in .project_id
102
+ # for the event "project_create" the project id is in .project_id
105
103
[ -z " $project_id " ] && project_id=" $( jq -r ' .project_id // empty' <<< " $json" ) "
106
104
107
105
project_name=" $( jq -r ' .project.path_with_namespace // empty' <<< " $json" ) "
106
+ # for the event "project_create" the project name is in: .path_with_namespace
107
+ [ -z " $project_name " ] && project_name=" $( jq -r ' .path_with_namespace // empty' <<< " $json" ) "
108
108
109
109
if [ -z " $project_id " ]; then
110
110
echo " Could not get the project id."
0 commit comments