echo"No trigger token found and can not create one"
exit 7
fi
fi
echo"Trigger pipeline ..."
gitlab 201 POST projects/"$PRJID"/trigger/pipeline --data"token=$TRIGGERTOKEN"--data"ref=${branch}"--data"variables[TRIGGERTASK]=$mode"--data"variables[TRIGGER_INPUT]=$branch"
PIPELINEID=$(echo"$result" | jq -r ."id")
PIPELINESTATUS=$(echo"$result" | jq -r ."status")
while[$PIPELINESTATUS!="success"]
do
sleep 3
gitlab 200 GET /projects/"$PRJID"/pipelines/"$PIPELINEID"
PIPELINESTATUS=$(echo"$result" | jq -r ."status")
echo" $PIPELINESTATUS ..."
case"${PIPELINESTATUS}"
in
created);;
pending);;
running);;
success);;
*)exit 8;;
esac
done
gitlab 200 GET /projects/"$PRJID"/pipelines/"$PIPELINEID"/jobs
JOBID=$(echo"$result" | jq -r .[0]."id")
gitlab 200 GET /projects/"$PRJID"/jobs/"$JOBID"/artifacts --output /tmp/artifacts.zip
echo"Extract archive ..."
unzip -o /tmp/artifacts.zip -d /tmp
if[["$mode"=="CollectDatabase"]];then
echo"Copy DB dump into PHP container ..."
docker compose cp /tmp/drupal.sql php:/tmp
echo"Import DB ..."
drush -y sql:drop
drush -y sql:query --file=/tmp/drupal.sql
fi
if[["$mode"=="CollectFiles"]];then
echo"Please move the files from /tmp into your file directories manually."