Skip to content

Instantly share code, notes, and snippets.

@jorgeuriarte
Created March 17, 2014 17:11
Show Gist options
  • Save jorgeuriarte/9603775 to your computer and use it in GitHub Desktop.
Save jorgeuriarte/9603775 to your computer and use it in GitHub Desktop.
Jira transition validator... will restrict transition if any issue is waiting in 'Testing' state for the given team.Thanks to examples like https://answers.atlassian.com/questions/134531/how-to-run-jql-query-inside-groovy-script
def user = componentManager.jiraAuthenticationContext.getLoggedInUser()
def campoCelula = componentManager.customFieldManager.customFieldObjects.find { it.fieldName.endsWith('lula IT') }
def celula = issue.getCustomFieldValue(campoCelula)
def jql = """
project = 'TICKETBIS'
and '${campoCelula.name}' = '${celula}'
and status = 'En Pruebas'
and assignee is null
"""
def searchService = componentManager.getSearchService()
def query = searchService.parseQuery(user, jql).getQuery()
def searchResult = searchService.search(user, query, com.atlassian.jira.web.bean.PagerFilter.unlimitedFilter)
def issuesEnPruebas = searchResult.issues.collect {
componentManager.issueManager.getIssueObject(it.id)
}
if (issuesEnPruebas.size() > 0) {
println "CM: ${issue}, ${user}"
invalidInputException = new com.opensymphony.workflow.InvalidInputException("Peticiones para probar antes de empezar nuevas? (${issuesEnPruebas})")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment