-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathworkflow.groovy
More file actions
37 lines (31 loc) · 1.31 KB
/
Copy pathworkflow.groovy
File metadata and controls
37 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Level
import org.apache.log4j.Logger
log.setLevel(Level.INFO)
// 测试时读取issue
//String issueKey = "DEMO-1"
//Issue issue = ComponentAccessor.getIssueManager().getIssueObject(issueKey)
//assert issue
//log.info String.format("%s, %s, %s", issue, issue.issueType.name, issue.status.name)
//String fieldName = "Story Points"
//CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(fieldName)
//String fieldValue = (String)issue.getCustomFieldValue(customField)
/**
* 在新建单据提交到数据库之前校验数据
*/
Double fieldValue = (Double) cfValues["Story Points"]
log.info String.format("value: %s", fieldValue)
if (fieldValue == null) {
return true
}
// 示例逻辑:数据可以不填,但是只允许某个权限组的用户填写
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (!ComponentAccessor.getGroupManager().isUserInGroup(user, "story_point_group")) {
return false
}
// 请输入正确的价值,范围1-100
Double value = Double.valueOf(fieldValue)
return value && value >= 1 && value <= 100