2012-12-20 69 views
2

我正在Groovy中編寫一個工作流驗證程序,以基於案例創建時的自定義字段值輸入鏈接兩個問題。要求對Jira問題鏈接的自定義字段值是唯一的。換句話說,我需要確保只有一個問題具有特定的自定義字段值。如果有多個問題具有輸入自定義字段值,則驗證應該失敗。Jira工作流腳本驗證程序的返回碼

如何返回或導致工作流驗證程序失敗?

示例代碼:

// Set up jqlQueryParser object 
jqlQueryParser = ComponentManager.getComponentInstanceOfType(JqlQueryParser.class) as JqlQueryParser 
// Form the JQL query 
query = jqlQueryParser.parseQuery('<my_jql_query>') 
// Set up SearchService object used to query Jira 
searchService = componentManager.getSearchService() 
// Run the query to get all issues with Article number that match input 
results = searchService.search(componentManager.getJiraAuthenticationContext().getUser(), query, PagerFilter.getUnlimitedFilter()) 
// Throw a FATAL level log statement because we should never have more than one case associated with a given KB article 
if (results.getIssues().size() > 1) { 
    for (r in results.getIssues()) { 
     log.fatal('Custom field has more than one Jira ssue associated with it. ' + r.getKey() + ' is one of the offending issues') 
    } 
    return "?????" 
} 

// Create link from new Improvement to parent issue 
for (r in results) { 
    IssueLinkManager.createIssueLink(issue.getId(), r.getId(), 10201, 1, getJiraAuthenticationContext().getUser()) 
} 

回答