Add new file
This commit is contained in:
parent
2d15fd771a
commit
4be19f2823
1 changed files with 33 additions and 0 deletions
33
setComponentCSV.sh
Normal file
33
setComponentCSV.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
jira_base_url="https://jira.someserver.com"
|
||||
username="usernName"
|
||||
password="passWord !@#"
|
||||
|
||||
csv_file="components.csv"
|
||||
|
||||
|
||||
# Read the CSV file line by line
|
||||
while IFS='|' read -r project_key component_name user_id; do
|
||||
# Remove carriage return characters from the component_name
|
||||
component_name=$(echo "$component_name" | tr -d '\r')
|
||||
|
||||
# Get the component ID from Jira API using project_key and component_name
|
||||
raw_data=$(curl -s -X GET \
|
||||
-u "$username:$password" \
|
||||
-H "Content-Type: application/json" \
|
||||
"$jira_base_url/rest/api/2/project/$project_key/components")
|
||||
component_id=$(echo "$raw_data" | jq -r --arg component_name "$component_name" '.[] | select(.name == $component_name) | .id')
|
||||
|
||||
echo "Updating project $project_key, component $component_name with new lead $user_id..."
|
||||
|
||||
# Update the component lead using the component ID and user ID
|
||||
curl -s -X PUT \
|
||||
-u "$username:$password" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"leadUserName\":\"$user_id\", \"assigneeType\": \"COMPONENT_LEAD\"}" \
|
||||
"$jira_base_url/rest/api/2/component/$component_id" > /dev/null
|
||||
|
||||
# Output the updated information with a timestamp
|
||||
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo "Updated project $project_key, component $component_name with new lead $user_id at $timestamp"
|
||||
done < "$csv_file"
|
Loading…
Add table
Add a link
Reference in a new issue