In our Jira system (server version) we have a Jira field called development that has data like this:
{summaryBean=com.atlassian.jira.plugin.devstatus.rest.SummaryBean@7b282e38[summary={pullrequest=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@58970e1f[overall=PullRequestOverallBean{stateCount=8, state='MERGED', details=PullRequestOverallDetails{openCount=0, mergedCount=8, declinedCount=0}},byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@3fa7f13e[count=8,name=GitHub Enterprise]}], build=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@5f20f723[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BuildOverallBean@75980dae[failedBuildCount=0,successfulBuildCount=0,unknownBuildCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], review=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@5249b39b[overall=com.atlassian.jira.plugin.devstatus.summary.beans.ReviewsOverallBean@52e796ed[stateCount=0,state=<null>,dueDate=<null>,overDue=false,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], deployment-environment=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@aa6fa7d[overall=com.atlassian.jira.plugin.devstatus.summary.beans.DeploymentOverallBean@3f6673fa[topEnvironments=[],showProjects=false,successfulCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], repository=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@20accae6[overall=com.atlassian.jira.plugin.devstatus.summary.beans.CommitOverallBean@4e1260e0[count=3,lastUpdated=2023-05-12T16:52:15.000-0700,lastUpdatedTimestamp=2023-05-12T16:52:15.000-07:00],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@735a1e4d[count=3,name=GitHub Enterprise]}], branch=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@7faf5a7f[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BranchOverallBean@39124496[count=1,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@645a2634[count=1,name=GitHub Enterprise]}]},errors=[],configErrors=[]], devSummaryJson={"cachedValue":{"errors":[],"configErrors":[],"summary":{"pullrequest":{"overall":{"count":8,"lastUpdated":"2023-05-12T17:30:27.000-0700","stateCount":8,"state":"MERGED","details":{"openCount":0,"mergedCount":8,"declinedCount":0,"total":8},"open":false},"byInstanceType":{"githube":{"count":8,"name":"GitHub Enterprise"}}},"build":{"overall":{"count":0,"lastUpdated":null,"failedBuildCount":0,"successfulBuildCount":0,"unknownBuildCount":0},"byInstanceType":{}},"review":{"overall":{"count":0,"lastUpdated":null,"stateCount":0,"state":null,"dueDate":null,"overDue":false,"completed":false},"byInstanceType":{}},"deployment-environment":{"overall":{"count":0,"lastUpdated":null,"topEnvironments":[],"showProjects":false,"successfulCount":0},"byInstanceType":{}},"repository":{"overall":{"count":3,"lastUpdated":"2023-05-12T16:52:15.000-0700"},"byInstanceType":{"githube":{"count":3,"name":"GitHub Enterprise"}}},"branch":{"overall":{"count":1,"lastUpdated":null},"byInstanceType":{"githube":{"count":1,"name":"GitHub Enterprise"}}}}},"isStale":true}}
I’m looking to create a custom formula in structure to extract PullRequestOverallDetails .mergedCount. In this example I'd want my custom field to display 8
Based on my research, this prior support request suggests that I should be able to create a formula similar to the below to extract a matched group
REPLACE(development; "/(PullRequestOverallDetails\{openCount=([0-9]+), mergedCount=([0-9]+), declinedCount=([0-9]+)\})/"; "$3")
unfortunately i’m only getting the unchanged development string back.
I used regex101.com to validate the regex
I’d love any help you could offer
other articles reviewed
* Use Structure Formula to extract text from summary field
Hello @snasello
The mergedCount= seems to be a unique combination of symbols, so you can try using it as reference in the formula like this:
left(split(development,"mergedCount=").last(), 1)
If you need further assistance, please reach out to us directly at our support portal.
Best regards,
Stepan Kholodov
Tempo
Hi @Stepan Kholodov _Tempo_ I'm very happy to have this option and it's working pretty well for mergedCount :).
I do need to grab one more piece of information out of this string that might not work with your suggestion.
I need to get the number of commits as well, given by the path of:
devSummaryJson.cachedValue.summary.pullrequest.repository.overall.count
Are there any regex options rather than using the split command?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.