2

ケース作成時に入力されたカスタムフィールド値に基づいて2つの問題をリンクするために、Groovyでワークフローバリデーターを作成しています。Jira発行リンクへのカスタムファイル値は一意である必要があります。つまり、特定のカスタムフィールド値を持つ問題が1つだけであることを確認する必要があります。入力カスタムフィールド値を持つ問題が複数ある場合、検証は失敗するはずです。

ワークフローバリデーターを失敗させるには、どのように、または何を返しますか?

コード例:

// 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())
}
4

1 に答える 1

1

次のようなものを試してください

import com.opensymphony.workflow.InvalidInputException
invalidInputException = new InvalidInputException("Validation failure")

これは、Groovyスクリプトランナーに基づいています。それがうまくいかない場合は、スクリプトを簡単にするために何らかのフレームワークを使用することをお勧めします。GroovyスクリプトランナーJira Scripting Suite、またはBehaviorsPluginのいずれかを使用するのが好き です。それらはすべて、スクリプトの記述をより簡単に、より直感的にします。

于 2012-12-23T10:04:07.447 に答える