Validate before transition
You can prevent the Jira issue from transition to the next state if not all Smart Checklist items are checked.
Since version, v5.2.0 Smart Checklist add-on doesn’t need “Smart Checklist Progress” field setup
If your Smart Checklist version is lower than v5.2.0 - Follow these instructions to add the "Smart Checklist Progress" custom field, then proceed to the steps below.
Set up transition validator
Go to Workflows
Choose one that you want to add validation to and click Edit
Choose transition and click on "Validators" link
Add Validator
Choose "Smart Checklist Completed Validator"
Click Add - new Validator will be saved
Then Publish this changed workflow
Check Validator in action
Go to Kanban board (or Issue view)
Try to change the state of an item with opened checklist items
You'll get the error:
If you check all Smart Checklist items - you'll be able to transition the Jira issue successfully!
If you want to know how to display "Show Checklist progress" on Agile boards read Progress on Agile Board
Validate if certain items are completed
You can add a validator that verifies if only certain items have been checked off before allowing the transition.
Let’s imagine, you have the following checklist:
The Checklists custom field will contain the following string:
# Definition of Done
+ Code produced (all to do items in code completed)
> Code commented, checked in and run against current version in source control
~ Code reviewed
> @Peer reviewed (or produced with pair programming)
> meeting development standards
- Builds without errors
- Unit tests written and passing
- Deployed to system test environment and passed system tests
- Acceptance criteria met
> Passed UAT (User Acceptance Testing)
> signed off as meeting requirements by@ProductOwner
- Any build/deployment/configuration changes implemented/documented/communicated
- Relevant documentation/diagrams produced and/or updated
Using Scripted (Groovy) Validator you can check if all items with the text 'Code reviewed' and 'Unit tests are written and passing' are done:
def checklist = issue.get("customfield_10113");
if (!checklist) {
return true;
}
def checklistItems = checklist.split('\n').findAll({ it -> it.matches("^[-|+|~].*")});
for (item in checklistItems) {
if (!item.startsWith("+") && (item.contains("Code reviewed") || item.contains("Unit tests written and passing"))) {
return false;
}
}
return true;
Fixing slow Issue transition with validation enabled
The following information could be helpful if the checklist validation is noticeably slowing down the Issue transition.
The validations are essentially based on the following query:
select * from "AO_C2A220_ITEM" acai
join "AO_C2A220_STATUS" acas on acai."STATUS_ID" = acas."ID"
join "AO_C2A220_CHECKLIST" acac on acai."CHECKLIST_ID" = acac."ID"
where acac."ENTITY_ID" =1279600
and acas."STATE" ='CHECKED'
and acai."IS_CHECKBOX"=true
and acai."MANDATORY" = true;
Update statistics
In order to assure the performance of that query, the database administrator needs to be sure that correct statistics are present in the database. This can be done with the following SQLs: