The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
For Readonly Insight Custom Field, "Filter Assign Scope (IQL)" only takes affect for newly created/updated issues as the filter only gets triggered upon a IssueCreated or IssueUpdated events.
As a result, as a Jira/Insight administrator it's difficult to automatically populate the "Readonly Insight Custom Field" values for existing issues until these issues are manually updated.
Read more here: JSDSERVER-8461 : Add ability to trigger "Filter Assign Scope" retroactively for existing issues
As the feature currently doesn't exist, I tried to write a bash script to invoke issue updates.
#!/bin/bash
# small script as a workaround for JSDSERVER-8461 : Add ability to trigger "Filter Assign Scope" retrospectively for existing issues
# Author: Mr. Doubt Everyhim
# Date: 2021-07-12
#
# PREREQUISITES:
# 1. Need to Install JQ: https://stedolan.github.io/jq/download/
# 2. Must have "Labels" added to "Default issue view screen" for all returned issues by JQL
# 3. User must have edit issue permission
admin_user=<USER>
admin_password=<PASSWORD>
jira_server="http://xxxxxxxx:8080/jira"
url_part2="/rest/api/2/search"
url_part3="/rest/api/2/issue"
FILE="search_results.json"
# Remove if exists
if [ -f "$FILE" ]; then
echo "$FILE exists..Renaming the file and continuing..."
mv "$FILE" $(date +%Y-%m-%d_%H-%M-%S)_"$FILE"
else
echo "$FILE does not exist. Continuing...."
fi
# Get matching issues and iterate over all the matching issues. change the c+=<VALUE> to change the "startAt" value:
for (( c=0; c<=20; c+=2 ))
do
curl --fail --silent --show-error ${jira_server}{$url_part2} -u ${admin_user}:${admin_password} -X POST -H 'Content-Type: application/json' --data-raw '{"jql": "project = Insight and cf[10301] is EMPTY", "startAt": '$c', "maxResults": 2, "fields": ["id","key"]}' |jq --compact-output '.issues[] | {id}' >> search_results.json
done
echo "JQL Results are written in ./search_results.json"
echo "Total issues returned: " $(cat $FILE |wc -l)
# Adding Label:
for i in $(cat ./search_results.json | sed 's/[^0-9]*//g'); do
echo "Adding label for Issue ID: " $i
curl ${jira_server}{$url_part3}/$i -u ${admin_user}:${admin_password} -X PUT -H 'Content-Type: application/json' --data-raw '{"update":{"labels":[{"add":"label_to_deleted"}]}}'
done
# Removing Label:
for i in $(cat ./search_results.json | sed 's/[^0-9]*//g'); do
echo "Removing label for Issue ID: " $i
curl ${jira_server}{$url_part3}/$i -u ${admin_user}:${admin_password} -X PUT -H 'Content-Type: application/json' --data-raw '{"update":{"labels":[{"remove":"label_to_deleted"}]}}'
done
echo "Done!"
Suddha
Atlassian TeamJira Support
Atlassian Indian LLP
Bangalore
2 accepted answers
Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
0 comments