jiragetinactivecomponentleads/getInactiveComponentLead.sh
2023-05-09 00:04:18 +00:00

27 lines
936 B
Bash

#!/bin/bash
jira_base_url="https://jira.someserver.com"
username="userName"
password="password !@#"
project_key="projectKey"
# 1. Pull a project's component list
raw_data=$(curl -s -X GET \
-u "$username:$password" \
-H "Content-Type: application/json" \
"$jira_base_url/rest/api/2/project/$project_key/components")
# 2. Create a mapping of component ID, component name, and the assignee name
component_data=$(echo "$raw_data" | jq -c '.[] | {id: .id, name: .name, lead: {name: .lead.name, active: .lead.active}}')
# 3. Check components for inactive leads
echo "Components with inactive leads:"
IFS=$'\n'
for component in $component_data; do
lead_active=$(echo "$component" | jq -r '.lead.active')
if [ "$lead_active" = "false" ]; then
component_name=$(echo "$component" | jq -r '.name')
lead_name=$(echo "$component" | jq -r '.lead.name')
echo "Component: $component_name, Inactive lead: $lead_name"
fi
done