[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gitlab API question: Fetching group ID works not reliably



On Tue, 15 May 2018, Andreas Tille wrote:

> Hi,
> 
> I'm using the following script to fetch the group ID of a salsa team:
> 
> #!/bin/sh
> 
> SALSA_URL="https://salsa.debian.org/api/v4";
> SALSA_TOKEN="MYSECRETTOKEN"
> 
> SALSA_GROUP="med-team"
> #SALSA_GROUP="science-team"
> #SALSA_GROUP="r-pkg-team"
> 
> SALSA_GROUP_ID=$(curl --silent -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" "$SALSA_URL/groups?all_available=false" | jq ".[] | select(.path == \"$SALSA_GROUP\") | .id")
> 
> echo "ID=$SALSA_GROUP_ID"
Sorry this is inefficient. If you know the name of the group, query the group
directly. 

Don't do it that way, that wastes a lot of ressources. 

SALSA_GROUP_ID=$(curl -s -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" "$SALSA_URL/groups/$SALSA_GROUP" | jq '.id')

Alex


Reply to: