REST API /rest/api/2/issueLink executes in the actual workflow time out

disconnect February 18, 2024

I added a Groovy script in the post-function , it's  create  an issue and issuelink the current issue.

However, I noticed that when it executes in the actual workflow, the issuelink API times out. Although the request timed out, the issuelink was successful in the end.

And i tested the script separately, and it worked fine. Could you please help me with this issue?

env:  jira software version 9.10.1,  centos7 

access_log find  "POST /rest/api/2/issueLink- HTTP/1.1" 500 55 50081 "-" "Java/11.0.13" "t6ydwf"

catalina.2024-02-18.log find :

18-Feb-2024 21:02:28.456 WARNING [Catalina-utility-1] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread [http-nio-8080-exec-3 url: /secure/CommentAssignIssue.jspa; user: sha**] (id=[24]) has been active for [121,529] milliseconds (since [2/18/24 9:00 PM]) to serve the same request for [http://*.link/secure/CommentAssignIssue.jspa?atl_token=***_lin] and may be stuck (configured threshold for this StuckThreadDetectionValve is [120] seconds). There is/are [1] thread(s) in total that are monitored by this Valve and may be stuck.

 

code about is:

 

for(user in allWorkers){
  log.error(user)
  def requestBody = """
      {
          "fields": {
              "issuetype": {"id": "10101" },
              "project": {"id": "10100" },
              "fixVersions": [{"name": "${fixVersions}"}], 
              "summary": "${summary}", 
              "priority": {"name": "${priority}" },
              "components": [{"name": "${component}"}], 
              "assignee": {"name": "${user}" },
              "reporter": {"name": "${reporter}" },
              "customfield_10216": {"value": "${needTest}" },
              "versions": [{"name": "${versions}"}]
            }
      }
"""
  def res = req.sendPostRequest(requestBody, "rest/api/2/issue")
  def slurper = new JsonSlurper()
  def result = slurper.parseText(res)
  log.error(res.toString() )
  def targetIssueKey = result.key
  result_key.add(targetIssueKey)
}
def req2 = new NewLinkIssue()
for(iKey in result_key){
      try{
        def linkReqBody = """{"type":{"name":"Relates"},"inwardIssue":{"key":"${sourceIssueKey}"},"outwardIssue":{"key":"${iKey}"},
    "comment": {"body": "Linked related issue!"}}"""
        log.error("start issueLink")
            req2.sendPostRequest(linkReqBody, "rest/api/2/issueLink")
        log.error("inwardIssue success")
    
      } catch(Exception e){
        log.error("inwardIssue failed")
      }
    }

3 answers

1 accepted

0 votes
Answer accepted
disconnect February 21, 2024

I fixed it.

The script must to be executed first

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 20, 2024

Welcome to the Atlassian Community!

Is this creating the links in another Jira system?

If it's the same Jira system the script is running in, then it's probably worth swapping to writing the code to run locally, using the java API instead of a remote REST call.

disconnect February 20, 2024

Thank you for your answer, it's the same Jira system the script is running in. running the Post Functions Groovy script.

Could you please give me a demo of using java API to impleme.

0 votes
disconnect February 19, 2024

anybody???

Suggest an answer

Log in or Sign up to answer