#!/bin/bash # Load environment variables from .env file source .env # Jira API URL to get issues assigned to the user in the current sprint with "READY FOR DEV" status JQL_QUERY="assignee=$ASSIGNEE_ID%20AND%20sprint%20in%20openSprints()%20AND%20project%20%3D%20%22$PROJECT_KEY%22" URL="https://$JIRA_DOMAIN/rest/agile/1.0/board/$BOARD_ID/issue?jql=$JQL_QUERY&maxResults=100" # Make the API request with curl response=$(curl -s -X GET "$URL" -H "Authorization: Basic $(echo -n "$EMAIL:$API_TOKEN" | base64)" -H "Accept: application/json") # Check if there are issues and filter by status "READY FOR DEV" issues_count=$(echo "$response" | jq '.issues | length') if [ -z "$issues_count" ]; then issues_count=0 fi if [ "$issues_count" -gt 0 ]; then echo "Issues Assigned to User in Current Sprint with Status 'READY FOR DEV' on Board $BOARD_ID:" echo "$response" | jq -r '.issues[] | select(.fields.status.name == "READY FOR DEV") | "\(.key) - \(.fields.summary) [Status: \(.fields.status.name)]"' else echo "No issues found assigned to the user in the current sprint with status 'READY FOR DEV'." fi
Hi,
I think there are some points to check, since you mentioned that in powershell it works. I would start by trying to use "--data-urlencode" to correctly encode JQL:
# Make the API request with curl
response=$(curl -s -X GET "$URL" \
-H "Authorization: Basic $(echo -n "$EMAIL:$API_TOKEN" | base64)" \
-H "Accept: application/json" \
--data-urlencode "jql=$JQL_QUERY" \
--data-urlencode "maxResults=100")
The & in the URL can be interpreted as a special character by the shell. --data-urlencode ensures that special characters such as = and spaces are correctly encoded.
I also noticed that your endpoint uses:
URL="https://$JIRA_DOMAIN/rest/agile/1.0/board/$BOARD_ID/issue?jql=$JQL_QUERY&maxResults=100"
In this case, it might be better to filter by:
URL="https://$JIRA_DOMAIN/rest/api/2/search?jql=$JQL_QUERY&maxResults=100"
If the JSON returned by Jira has no issues, JQ may fail. Check with:
echo "Response: $response"
If there is an error, it may be that JQ is unable to process the response.
If you are receiving any type of error, it would be interesting to share so we can go into more detail.
P.S: Remembering that these are some of the things I would do in my script to try to get the result, I hope it helps you in some way, or else it brings an error so we can analyze it better
Best Regards.
@Layssa Souza thx for those updates ,I tried using those updates but no results,no errors ,
if you could provide a working similar bash script using curl to list current tickets with a status filter in current open sprint for auth using email,apitoken
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
similar script in powershell works ,shows current tickets
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.