Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trigger "Filter Assign Scope" retroactively (Possible workaround for JSDSERVER-8461)

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!"

 

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

87 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you