Commit ce11ffb9 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Workaround for using the group access token to trigger the pipeline for each project

parent cb0f2f54
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -14,7 +14,17 @@ PROJECT_IDS="41" # Use TS-0019 for debugging
# Trigger pipeline for each project. Triggered pipeline pages job will handle the upgrade of the index.html
for PROJECT_ID in $PROJECT_IDS; do
	echo "------ Preparing specification project --------"
    curl -X POST --fail -F token=$1 -F ref=main https://git.onem2m.org/api/v4/projects/$PROJECT_ID/trigger/pipeline
	#WORKAROUND UNTIL ACCESS TOKEN WORKS FOR TRIGGERING A PIPELINE (right now, it is allowed but it seems NOT to work)
	#create a pipeline trigger token first
	echo "------ Creating pipeline trigger token --------"
	PIPELINE_TRIGGER_TOKEN_ID=$(curl --request POST --header "PRIVATE-TOKEN:$1" --form description="Temporary pipeline trigger token for tools/scripts" https://git.onem2m.org/api/v4/projects/$PROJECT_ID/triggers | grep -o '"id":[^,]*,"token"'|cut -d',' -f1 | cut -d':' -f2)
    PIPELINE_TRIGGER_TOKEN=$(curl --header "PRIVATE-TOKEN:$1" https://git.onem2m.org/api/v4/projects/$PROJECT_ID/triggers/$PIPELINE_TRIGGER_TOKEN_ID | grep -o '"token":[^,]*'|cut -d'"' -f4)
    echo "------ Triggering pipeline --------"
	#trigger the pipeline
    curl -X POST --fail -F token=$PIPELINE_TRIGGER_TOKEN -F ref=main https://git.onem2m.org/api/v4/projects/$PROJECT_ID/trigger/pipeline
    echo "------ Deleting pipeline trigger token (NOTE that information about the token that caused the pipeline will NOT be available for the pipeline) --------"
	#remove the pipeline trigger token
    curl --request DELETE --header "PRIVATE-TOKEN:$1" "https://git.onem2m.org/api/v4/projects/$PROJECT_ID/triggers/$PIPELINE_TRIGGER_TOKEN_ID"
done

exit 0
 No newline at end of file