Skip to content
Snippets Groups Projects
Commit c293521f authored by jurgenhaas's avatar jurgenhaas
Browse files

gitlab-ci-cd/drupal#30 Improve handling of pipeline trigger tokens

Ignore archived projects
parent c80d163d
No related branches found
No related tags found
1 merge request!19Merging develop into main
......@@ -90,7 +90,7 @@ else
echo "Find project ID from remote URL ..."
# shellcheck disable=SC2001
path="$(echo "$path" | sed -e 's,\..*,,g')"
gitlab 200 GET "projects?search_namespaces=1&search=$path"
gitlab 200 GET "projects?archived=0&search_namespaces=1&search=$path"
PRJID=$(echo "$result" | jq -r .[0]."id")
if [[ "a${PRJID}a" == "aa" ]]; then
echo "No project found"
......@@ -104,10 +104,28 @@ fi
echo "Find pipeline trigger token ..."
gitlab 200 GET projects/"$PRJID"/triggers
TRIGGERTOKEN=$(echo "$result" | jq -r .[0]."token")
if [[ "a${TRIGGERTOKEN}a" == "aa" ]]; then
echo "No trigger token found"
exit 7
TRIGGERTOKEN=none
i=0
while [ $i -ge 0 ]
do
TOKEN=$(echo "$result" | jq -r .[$i]."token")
if [[ "$TOKEN" == "null" ]]; then
i=-1
elif [[ ${#TOKEN} -eq 4 ]]; then
((i=i+1))
else
TRIGGERTOKEN=$TOKEN
i=-1
fi
done
if [[ "$TRIGGERTOKEN" == "none" ]] || [[ "a${TRIGGERTOKEN}a" == "aa" ]]; then
echo "No token found, creating one ..."
gitlab 201 POST projects/"$PRJID"/triggers --data "description=Created by L3D"
TRIGGERTOKEN=$(echo "$result" | jq -r ."token")
if [[ "$TRIGGERTOKEN" == "none" ]] || [[ "a${TRIGGERTOKEN}a" == "aa" ]]; then
echo "No trigger token found and can not create one"
exit 7
fi
fi
echo "Trigger pipeline ..."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment