2013-09-27 121 views
0

在這裏工作是一個代碼:JIRA登錄使用Groovy腳本問題

CM = ComponentManager.getInstance() 
worklogManager = CM.getWorklogManager() 

for(int i=0; i<=4; i++) { 
    worklog = new WorklogImpl(worklogManager, issue, null, issue.reporter.name, issue.summary, new Date(), null, null, 1*3600) 
    worklogManager.create(issue.reporter, worklog, 0L, false) 
} 

OR

for(int i=0; i<=4; i++) { 
    params = WorklogInputParametersImpl 
     .issue(issue) 
     .startDate(new Date()) 
     .timeSpent('1h') 
     .comment('123') 
     .buildNewEstimate() 

    result = wls.validateCreate(context, params) 
    wls.createAndAutoAdjustRemainingEstimate(context, result, true) 
} 

這裏是一個結果:

5工作日誌條目,用時1小時花 但是記錄:只顯示1小時而不是5小時

JIRA 6.1最新腳本亞軍插件6.1 與JIRA 5.1.7相同結果

任何想法?

謝謝!

謝爾蓋

enter image description here

+0

你調用'.buildNewEstimate()'但有打電話來重新計算總花了幾個小時的方法? –

+1

@BorislavSabev我不這麼認爲https://developer.atlassian.com/static/javadoc/jira/6.0/reference/com/atlassian/jira/bc/issue/worklog/WorklogInputParametersImpl.Builder.html#buildNewEstimate() –

回答

0

解決方案是計算手動記錄的時間:

for(int i=0; i=4; i++) { 
    worklog = new WorklogImpl(
     worklogManager, 
     issue, 
     null, 
     issue.reporter.name, 
     issue.summary, 
     new Date(), 
     null, 
     null, 
     1*3600 
    ) 
    worklogManager.create(issue.reporter, worklog, 0L, false) 
    issue.timeSpent = issue.timeSpent == null 
     ? 1*3600 
     : issue.timeSpent + 1*3600 
} 
1

我也有類似的問題,在worklogManager.create()改變的最後一個參數true解決了這個問題。它調度我認爲正確行爲所需的ISSUE_WORKLOGGED_ID事件。