# milestone-remover.sh
#!/bin/bash
# Importes
source ./includes/global.sh
issues=$(get_closed_milestones)
for milestone_id in $(jq -c '.[] | .id'<<< "$issues"); do
milestone_id= echo ${milestone_id%/r}
# If not null
if [ ! "$milestone_id" == "null/r" ];
then
remove_milestone $milestone_id
fi
done
I had to use the ! "$milestone_id" == "null/r" cause I realize I did get null like this.
It is looking a bit stang but it did send the request. I’ll then had this response
https://gitlab.entepriseName.ch/api/v4/groups/entepriseName/milestones/279
curl: (3) URL using bad/illegal format or missing URL
Is it correct that the groupname is also the enterprisename? I’d expect that the groupname is different, and that the $1 var doesn’t contain the correct groupname.
Edit: sorry I read that wrong, but I can’t see how you’ve put the group_name into the script, but you’d expect that to be the same as during the getting, so if you have a list of milestone_id’s, you’d expect that part to work
created a testgroup and milestone and could remove the milestone with a DELETE query to api/v4/groups/testgroup/milestones/milestone_id (I did use the group_name and not the group ID). I did add a Content-Type application/json header, I can’t see whether you included that.
Not sure where the /r is needed for.
When I pipe json replies through jq, I usually do it when creating a list of ID’s (directly after the curl request or in a separate processing step, not storing the raw json and use an inline processing, but that might be more a personal preference.
I can’t see how you’ve put the group_name into the script,
Yes, I get the correct milestones, this part is working as expected
but that might be more a personal preference.
No, that is a lake of knowledge and I do not know how to loop direct after the curl request but I’ll search, maybe you have a tips for that '^^
Not sure where the /r is needed for.
I had to add this, maybe because I do the loop in an ugly way
Content-Type application/json header
Did you add it for the get request ? It may be the reason why I had to work with the string instead of the json. If this is for the DELETE request, I do not understand the use of it, is it required ?