Something went wrong. Try again.
my dotfiles, managed with chezmoi
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546#!/bin/bash
JIRA_URL="https://joinhonor.atlassian.net"
# Check if input string is providedif [ $# -eq 0 ]; then echo "Usage: $0 <input_string> [--url]" exit 1fi
INPUT_STRING=""SHOW_URL=false
# Parse argumentsfor arg in "$@"; do if [ "$arg" == "--url" ]; then SHOW_URL=true else INPUT_STRING="$arg" fidone
# Extract ticket ID using regex (assuming ticket ID format is ABC-123)if [[ $INPUT_STRING =~ ([A-Za-z]+-[0-9]+) ]]; then TICKET_ID=${BASH_REMATCH[1]}else # No valid ticket ID found in input string. exit 2fi
if [ "$SHOW_URL" == true ]; then echo "$JIRA_URL/browse/$TICKET_ID"else
JIRA_EMAIL="nagee.elghassein@joinhonor.com" JIRA_API_TOKEN=$(op item get "jira API token" --fields label=password) RESPONSE=$(http --auth "$JIRA_EMAIL:$JIRA_API_TOKEN" GET "$JIRA_URL/rest/api/2/issue/$TICKET_ID") TITLE=$(echo $RESPONSE | jq -r '.fields.summary') # Check if the title was extracted successfully if [ -z "$TITLE" ]; then # Failed to retrieve the ticket title. Please check the ticket ID and API token. exit 3 fi echo $TITLEfi