You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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 TeamSenior Support Engineer
Atlassian B.V.
Amsterdam
2 accepted answers
0 comments