-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfield.groovy
More file actions
33 lines (26 loc) · 1.01 KB
/
Copy pathfield.groovy
File metadata and controls
33 lines (26 loc) · 1.01 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
import com.atlassian.jira.component.ComponentAccessor
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, %s", issue, issue.projectObject.key, issue.issueType.name, issue.status.name)
// 某个项目下的某类单据
if (issue.projectObject.key != "DEMO" || issue.issueType.name != "Story" || issue.status.name == "Done" || !issue.dueDate) {
return null
}
Date date = issue.dueDate
if (!date) {
// 读取字段
String fieldName = "StartDate"
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(fieldName)
date = (Date) issue.getCustomFieldValue(customField)
}
if (!date) {
return null
}
return (int) ((new Date().getTime() - date.getTime()) / 1000 / 3600 / 24)