Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to bulk delete gitlab issues.
#!/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
You can’t perform that action at this time.