how to access Issue development field information (such commits)

roger layani April 10, 2023

I want to read issue Development field information (commits) with groovy post function script

the  plugin  com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService seems to not be no more  available.

we use the JDC 8.20.0 version server

Can someone advise how to do this?

1 answer

1 accepted

1 vote
Answer accepted
roger layani April 17, 2023
At the end I found the answer to my question.
using following groovy script
================================================
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService
import com.atlassian.plugin.module.ContainerManagedPlugin
import com.atlassian.plugin.PluginState
def getCommitsList(Issue issue){
    Map commitsMap = [:]
    @WithPlugin('com.atlassian.jira.plugins.jira-development-integration-plugin')
    DevStatusSummaryService devStatusSummaryService = null

    def plugin = ComponentAccessor.pluginAccessor.getPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin")
    def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
    if (plugin instanceof ContainerManagedPlugin && plugin.pluginState == PluginState.ENABLED) {
        def beans = plugin.getContainerAccessor().getBeansOfType(DevStatusSummaryService)
        if (beans.size() > 0) {
            devStatusSummaryService = beans.first()
        }
    }
    def data = devStatusSummaryService.getDetailData(issue.id, "githube", "repository", currentUser).right().get()
    def items = data['detail']['repositories']
    items.each{ repos->   
        repos.each {repo->
            repo.each{ commits->      
                commits.each {commit->
                    def commit_sha = commit["displayId"]
                    def commit_url = commit["url"]            
                    commitsMap.put(commit_sha ,commit_url);
                }
            }
        }
    }
    return commitsMap
}
================================================
aas April 25, 2023

Thanks a lot, it helped me very much! Now I can get set of commit authors

    def items = data['detail']['repositories']
    items.each{ repos->
        repos.each {repo->
            repo.each{ commits->
                commits.each {commit->
                    if (commit["message"].toString().contains(issue.key)){
                        def authorName = commit["author"]["name"]
                        authors.add(authorName)
                    }
                }
            }
        }
    }
    return authors as Set
alex March 27, 2024

@roger layaniCouldn't tell me how to get a pullrequest from GitLab.
there is an entry in the task

def data = devStatusSummaryService.getDetailData(issue.id, "gitlab""pullrequest", currentUser).right().get()


I get an empty response
com.atlassian.jira.plugin.devstatus.rest.DetailBean@59544878[detail=[],errors=[],configErrors=]

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events