How to enable permissions on moving a JIRA ticket (transitions API) across my team's board?

Austin Serif October 16, 2023

One month ago I wrote a Github Actions Workflow that 1. Finds any JIRA issue numbers in a merged pull request, and 2. Uses the JIRA rest API to move those tickets into a target repo/environment (in this case it is Staging and Production). 

Here is the API call portion of my script:

```

- name: Send HTTP Request
run: |
str="${{ github.event.pull_request.body }} ${{ github.event.pull_request.title}} ${{ steps.get_head_commit_message.outputs.head-commit-message }}"
echo $str

jira_ids=$(echo "$str" | grep -o "[A-Z]*-[0-9]*")
echo $jira_ids

# Convert string of JIRA ids to array
jira_ids_arr=($jira_ids)

staging_deployed="2"
production_deployed="31"


if [[ ${{ github.ref }} == "staging" ]]
then
env=$staging_deployed
elif [[ ${{ github.ref }} == "main" ]]
then
env=$production_deployed
else
env="1"
fi

# Print each JIRA id
for id in "${jira_ids_arr[@]}"; do

curl \
-u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} \
-X POST \
--data '{"transition":{"id":'$env'}}' \
-H "Content-Type: application/json" \
${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/$id/transitions
done

```

It worked for a week or two, and then seemingly out of nowhere I was presented with the following error: 

```
{"errorMessages":["Can't move (SCRUM-27). You might not have permission, or the issue is missing required information. If you keep having this problem, contact your Jira Administrator."],"errors":{}}

```

I've tried:
1. Checking that the target transition ids are correct 

2. Updating the API key several times 

3. Confirming that my email (Org Admin) and all other keys/secrets are correct and properly stored/declared in github's secrets manager

 

During the time between when it worked and it started failing, the only change to my JIRA organization (which uses the Free tier) was that I added two new users.

 

Any help would be greatly appreciated, as it took me a while to get the script working in the first place.

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2023

Hello @Austin Serif 

Welcome to the Atlassian community.

Have you checked to see if the workflow has been edited or replaced since the last time it ran successfully?

Does the transition include Validators that are blocking the transition? Are there Conditions on the transition that would prevent it from transitioning?

Have you confirmed that the user used by the API can execute the transition manually through the UI?

Austin Serif October 16, 2023

Hi @Trudy Claspill, thanks for your reply.

 

1. Unsure of whether or not an accidental workflow update was made previously, I performed modifications to the transitions and retrieved the new transition ids.

2. No rules (including validation rules) are attached to any of the transitions in my workflow.

3. The user whose credentials are passed to the REST API is able to successfully move items across the board as expected, including where transition modifications were made. 

4. Lastly I tested the API call both when the target JIRA issue is unassigned and when the issue is assigned to the user whose credentials are used in the API call.

Unfortunately, the same error was produced in each case.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2023

Is the target issue in a Team Managed project or a Company Managed project?

How did you verify the transition IDs?

Do you have any logging that tells you what transition ID value is actually getting used in the API call?

What transition has ID = 1; the default you use at the bottom of the IF block?

Austin Serif October 17, 2023

The transition ids were verified by inspecting the response data returned by my-atlassian-domain.net/gateway/api/jira/project-configuration/query/93c61771-74fd-445f-94d7-e0193277eff8/2/workflow. This call is triggered whenever I enter the edit workflow page.

Using the property path `workflows[0].transitions[6]` I access the following transition data, which refers to the transition from Staging Deployed to Production Deployed statuses:

{
    "id": "6",
     "type": "DIRECTED",
      "from": [
           {
                "statusReference": "10005",
                "port": 3
           }
      ],
      "to": {
            "statusReference": "10006",
            "port": 7
       },
       "name": "Production Release",
       "description": "",
       "actions": [],
       "validators": [],
       "triggers": [],
       "properties": {}
}

 Similarly, the following transition refers to issues moved from In Progress or In Review to Staging Deployed:


{
"id": "8",
"type": "DIRECTED",
"from": [
{
"statusReference": "10001",
"port": 0
},
{
"statusReference": "10004",
"port": 0
}
],
"to": {
"statusReference": "10005",
"port": 7
},
"name": "Staging Deployed",
"description": "",
"actions": [],
"validators": [],
"triggers": [],
"properties": {}
}

 

2. Yes, I have logging that confirms the transition ids found above are passed to the API call.

 

3. transition_id = 1 is the To do column. This was including during earlier debugging and not removed. It should be removed, but according to available logs that transition id has never been set or passed so isn't a huge concern. 

 

4. I will check about team vs company project. It should be a team project since this is a small project run but myself and includes only a handful of other people, not sure how I could have made it a company project accidentally.

Austin Serif October 17, 2023

@Trudy Claspill 

It turns out my logs were misplaced and you were right! I was able to resolve it immediately following.. thanks so much!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events