Skip to content

Instantly share code, notes, and snippets.

@AnotherProksY
Created April 29, 2021 07:37
Show Gist options
  • Save AnotherProksY/57ad81b58a9306e6e6edf8c3bd02590b to your computer and use it in GitHub Desktop.
Save AnotherProksY/57ad81b58a9306e6e6edf8c3bd02590b to your computer and use it in GitHub Desktop.
Confluence get all users from groups via REST API
#!/bin/bash
declare -a StringArray=("confluence-users" "confluence-administrators")
# I use httpie instead of curl, but you can adapt this script to use cURL.
for group in ${StringArray[@]}; do
output=$(https -b -a 'username:password' https://<base-confluence-url>/rest/api/group/$group/member | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | grep displayName | cut -d ':' -f2 | sed -e 's/^"//' -e 's/"$//' | tr '\n' ',')
echo "$group;$output" >> any_filename_to_store_data.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment