Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

disconnect February 18, 2024 edited

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-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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 edited

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
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events