Обновление времени, затраченного на рабочие журналы проблем - malikovalibek/groovyForJira GitHub Wiki

Обзор Обновите время, затраченное на все рабочие журналы проблемы.

пример Как администратор, я хочу исправить рабочие журналы проблемы, чтобы отображать правильное время. Используя этот скрипт, я могу одновременно массово обновлять все рабочие журналы проблемы, экономя время и снижая риск ошибки.

Хорошо знать Вы должны выполнить сценарий как «Дополнительный пользователь ScriptRunner», чтобы отменить безопасность экрана. Вы можете точно настроить рабочие журналы для обновления, применяя дополнительные параметры запроса или дополнительные условия на основе атрибутов к поисковому запросу рабочего журнала . С участием ScriptRunner для Jira от Adaptavist

Создано 8 месяцев назад , Обновлено 4 месяца назад

Облачный код

Требования Jira Jira

// Specify the issue to set the worklog on final issueKey = "TEST-1"

// Specify the time to be set on each worklog (format: 24m for 24 minutes or 2h for 2 hours) final timeSpentValue = "1h"

// Execute the rest call to get all worklogs of an issue def issueWorklogs = get("/rest/api/2/issue/${issueKey}/worklog") .header('Content-Type', 'application/json') .asObject(Map).body.worklogs as List logger.info("The worklogs of issue ${issueKey}: ${issueWorklogs}")

// Iterate over each worklog def statusByWorklogId = issueWorklogs.collectEntries { worklog -> // Execute the rest call to update the worklog on the issue def result = put("/rest/api/2/issue/${issueKey}/worklog/${worklog.id}") .header('Content-Type', 'application/json') // Override screen security if the field is not on screen (this means the script must be run as the "ScriptRunner Add-On User") .queryString("overrideScreenSecurity", true) .body([ // Specify the time to be set updated on the worklog "timeSpent": timeSpentValue ]) .asObject(Map)

// Log out the issues transitioned or which failed to be transitioned
if (result.status == 200) {
    logger.info("Update of worklog ${worklog.id} performed successfully")
} else {
    logger.warn("Failed to update the worklog ${worklog.id}")
}

// Collect the success status by worklog key to show them as part of the script return value
[(worklog.id): (result.status == 200)]

}

"Status by worklog id (updated?): ${statusByWorklogId}"

⚠️ **GitHub.com Fallback** ⚠️