Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

scriptrunner plugin

Edited

Good afternoon. There is a script runner plugin, which for some reason does not work quite correctly, maybe I missed some settings in the fat itself. There is a certain code, it creates a task in which the performer and the leader of the performer are linked, but for some reason the link to the leader does not come k1TL0DSMBq8.jpg

 String linkName = "Объяснение"
String projectKey = "CHECKS"
String taskTypeId = 10812 //Объяснение
String jql = "filter=14612"
Long startAt = 0
Long maxResults = 100
Long total = 1
while (startAt < total) {
//logger.info("startAt=${startAt}, maxResults=${maxResults}, total=${total}")
def response = get("/rest/api/2/search?startAt=${startAt}&maxResults=${maxResults}&jql=${jql}")
.header('Content-Type', 'application/json')
.asObject(Map)

response.body.issues.each { issue ->
//Отсечём задачи в которых текущий исполнитель - неактивный пользователь.
def responseAssignee = get("/rest/api/2/user?accountId=${issue.fields.assignee.accountId}")
.header('Content-Type', 'application/json')
.asObject(Map)
boolean assigneeIsActive = responseAssignee.body.active
if(assigneeIsActive){
createLinkedIssue(issue, projectKey, taskTypeId, linkName)
}
}
startAt += maxResults
total = response.body.total

}
def createLinkedIssue(issue, projectKey, taskTypeId, linkName) {
//создание задачи и линковка
Date date = new Date() +1
Calendar calendar = Calendar.getInstance()
calendar.setTime(date)

String dueDate = "${calendar.get(Calendar.YEAR)}-${addZeros(calendar.get(Calendar.MONTH)+1)}-${addZeros(calendar.get(Calendar.DAY_OF_MONTH))}"
//создание задачи
newIssueResult = post('/rest/api/3/issue')
.header('Content-Type', 'application/json')
.body([
fields: [
summary : "Обяснительная по задаче ${issue.key}",
description: [
"type": "doc",
"version": 1,
"content": [
[
"type": "paragraph",
"content": [
[
"type": "mention",
"attrs": [
"id": issue.fields.assignee.accountId,
"userType": "APP"
]
],
[
"type": "text",
"text": ", просьба указать причину просрочки по задаче ${issue.key}.\nСделать это можно по кнопке \"Направить отчёт\"\n\n@Руководитель, просьба классифицировать просрочку.\nСделать это можно по кнопке \"Классифицировать по причинам\""
]
]
]
]
],
project : [
key: projectKey
],
issuetype : [
id: taskTypeId
],
reporter: [
"id": issue.fields.reporter.accountId
],
assignee: [
"id": issue.fields.assignee.accountId
],
duedate: dueDate
]
])
.asObject(Map)
newIssueKey = newIssueResult.body.key
oldIssueKey = issue.key
logger.info("newIssueKey=${newIssueKey}")
//линковка задачи
post("/rest/api/3/issueLink")
.header('Content-Type', 'application/json')
.body([
"outwardIssue": ["key": oldIssueKey],
"inwardIssue": ["key": newIssueKey],
"type": ["name": linkName]
]).asObject(Map)
}
String addZeros(Integer i){
if(i < 10){
return "0${i}"
}else{
return "${i}"
}
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events