Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Resolve Jira issues automatically from the commit message

Use the Git commit message to automate your Jira workflow

Automatically resolving a Jira issue from the Git (or other VCS) commit message means that the Jira issue mentioned in the commit message is transitioned at push time without manually updating the status in Jira. It's a frequent use case of DevOps automation rules that updates issues accidentally left in "In-progress" status. It takes some administrative burden off of developers and keeps your agile process on track.

For example, if your commit message is

"Fix the SAM-12 bug."

the SAM-12 issue will be automatically transitioned to "Done" status.

Follow the steps below to build your own DevOps automation rule that sends issues to "Done" status with a command in the Git (or other VCS) commit message.

The below rule is implemented with the free Better DevOps Automation for Jira. It's similar to Smart Commits, but more flexible and works for Data Center (Server) customers as well (who tend not to get the best DevOps automation features natively.)

Resolve Jira issues from the commit message

  1. Create a new Automation for Jira rule and select the "Commit created" trigger from the DevOps trigger category.

  2. Add a new Condition.
  3. Select the Advanced compare condition.
    3.1. Enter {{devops.commit.message}} to the First value field.
    3.2. Choose the contains regular expression option from the Condition dropdown.
    3.3. Enter (?si)(\bfix\b|\bfixes\b|\bfixed\b) to the Second value field.


  4. Save and add a "Run Groovy script" action.


  5. Add a description that clearly states what this DevOps automation rule will achieve. For example, add "Transition issue to "Done" as committer".
  6. Add this Groovy script:

    import com.atlassian.jira.component.ComponentAccessor
    def issueService = ComponentAccessor.issueService
    if (!issues) {
    def sourceStatusId = jiraHelper.getStatusByName("In Progress").iddef targetStatusId = jiraHelper.getStatusByName("Done").id
    def author = devops.committerByUsername ?: {throw new IllegalArgumentException("No user found with username \"${devops.commit.username}\"")}()
    // def author = devops.committerByEmailAddress ?: {throw new IllegalArgumentException("No user found with email address \"${devops.commit.emailAddress}\"")}() // (alternative, see the Smart Value Reference!)issues.forEach { issue ->
    	if ( != sourceStatusId) {
    	try {
    		def transitionId = jiraHelper.getTransitionByTargetStatus(issue.key, Long.valueOf((String) targetStatusId)).transitionId
    		def validationResult = issueService.validateTransition(author,, transitionId as int, issueService.newIssueInputParameters())
    		if (validationResult.isValid()) {
    			def issueResult = issueService.transition(author, validationResult)
    			if ( == targetStatusId) {"${issue.key} transitioned to <${}>")
    			} else {				auditLog.error("${issue.key} not transitioned! (check the workflow configuration!)")
    		} else {
    			(validationResult.errorCollection.errors.collect { "<${it.key}> field error: ${it.value}" } + validationResult.errorCollection.errorMessages).each { auditLog.error(it) }
    	} catch (Exception e) {		auditLog.error(e.message ?: "${e} ${e.stackTrace}")

  7. Name and save your automation rule.


What you need for this DevOps automation rule

  1. Better Commit Policy for Jira (PAID)
  2. Better DevOps Automation for Jira (FREE)
  3. Automation for Jira (PAID/FREE)

Read more on how these apps work together to create a fully flexible DevOps automation framework (using custom commands) based on Jira!

Did it work for you? Have a tricky use case? Share your questions or thoughts in the comments below! ⬇️



Log in or Sign up to comment
AUG Leaders

Atlassian Community Events