In our Bitbucket Data Centre we want to find out a list of users who have gone unlicensed because of not logging or inactivity .
I want to know if there is a way get the details of all those users so that we can have proper governance in place .
#!/bin/bash
BUSER=$1
BPASSWD=$2
BITBUCKET_URL=https://bitbucket.company.com
if [ $# -ne 2 ]; then
echo "Usage: $0 [Bitbucket users] [Bitbucket password]"
exit 1
fi
curl -s -u "$BUSER:$BPASSWD" -X GET "$BITBUCKET_URL/rest/api/1.0/users?permission=LICENSED_USER&limit=2000" | jq > /tmp/users
grep displayName /tmp/users | cut -d ":" -f 2 | sed -e 's/"//' | sed -e 's/",//'
This script requires jq which you can install with your package manager:
sudo apt install jq
sudo yum install jq
Also is there a way to figure out how many users have generated tokens for their accounts ?
Suppose a user doesnt login but is using his token in jobs , and if we remove him , his token can get invalid .
So we want to get this details as well .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Rajat Roy
This will help you out: https://stackoverflow.com/questions/49616922/in-bitbucket-api-how-can-i-get-a-list-of-all-licensed-users
Look for the answer from Marcelo. And also the comment from dave right bellow Marcelo's answer where it says that the mentioned code snippet from the page also includes the unlicensed users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.