Created
June 21, 2019 02:53
-
-
Save corycollier/dac5f7042ff30e64f91cbc284f94a116 to your computer and use it in GitHub Desktop.
Script to bulk delete gitlab issues.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
declare -i _page=0 | |
declare -i _number_of_pages=0 | |
declare _person_access_token="asdfasdfasdfsadf" | |
declare _gitlab_host="https://gitlab.example.com/api/v4" | |
declare _assignee="12345" | |
declare _url="${_gitlab_host}/issues?private_token=${_person_access_token}&assignee=${_assignee}&per_page=100" | |
_number_of_pages=$(curl -i -I "${_url}" | grep x-total-pages | awk '{print $2}' | sed 's/[^0-9]*//g') | |
while [ $_page -lt "$_number_of_pages" ]; do | |
_page=$((_page+1)) | |
_url="${_gitlab_host}/v4/issues?private_token=${_person_access_token}&assignee=${_assignee}&per_page=100&page=${_page}" | |
_data=$(curl "${_url}" | jq -r '.[] | "\(.iid) \(.project_id)"') | |
while read -r _info; do | |
echo "Project [${_project_id}] Issue [${_issue_iid}]" | |
_issue_iid=$(echo "${_info}" | awk '{print $1}') | |
_project_id=$(echo "${_info}" | awk '{print $2}') | |
_url="${_gitlab_host}/projects/${_project_id}/issues/${_issue_iid}" | |
curl --request DELETE --header "PRIVATE-TOKEN: ${_person_access_token}" "${_url}" | |
done <<< "${_data}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment