28 lines
959 B
Bash
Executable File
28 lines
959 B
Bash
Executable File
#!/bin/sh
|
|
|
|
JIRA_URL="https://jira.atg-corp.com"
|
|
TOKEN="NDQ0ODE5ODQ5NDU0OkwyY36wdY9DAvXsBr1M4bMjFmp6"
|
|
QUERY='project = "IS" AND status in (Open, "In Progress", Blocked, "Waiting for Customer", Stalled) AND assignee in (currentUser())'
|
|
TODAY="$(date +%Y-%m-%d)"
|
|
TODO_FILE="$HOME/docs/todo/todo.txt"
|
|
TEMP_FILE="$(mktemp)"
|
|
|
|
# Encode JQL query
|
|
ENCODED_QUERY=$(printf '%s' "$QUERY" | jq -s -R -r @uri)
|
|
|
|
# Fetch JIRA issues (requires `curl` and `jq`)
|
|
curl -s -H "Authorization: Bearer $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
"$JIRA_URL/rest/api/2/search?jql=$ENCODED_QUERY" |
|
|
jq -r '.issues[] | [.key, .fields.summary, .self] | @tsv' > "$TEMP_FILE"
|
|
|
|
# Prevent duplicates and append new tasks
|
|
while IFS=$'\t' read -r key summary url; do
|
|
if ! grep -q "\[$key\]" "$TODO_FILE"; then
|
|
printf "(%s) [%s] %s @jira\n" "$TODAY" "$key" "$summary" >> "$TODO_FILE"
|
|
echo "Added [$key] $summary"
|
|
fi
|
|
done < "$TEMP_FILE"
|
|
|
|
rm -f "$TEMP_FILE"
|