Created
August 15, 2024 15:13
-
-
Save vikrantyadav11/a96215ecec157305c9caf7ede5a19476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fieldsResponse = get('/rest/api/2/field').asObject(List).body | |
def fieldCounts = [:] | |
fieldsResponse.each { field -> | |
def fieldId = field.id | |
def fieldName = field.name | |
def fieldType = field.schema?.type ?: 'N/A' | |
def jqlQuery | |
if (fieldId.startsWith('customfield_')) { | |
def customFieldId = fieldId.replace('customfield_', '') | |
jqlQuery = "cf[$customFieldId] is not empty" | |
} else { | |
jqlQuery = "$fieldId is not empty" | |
} | |
def searchResult = get('/rest/api/2/search') | |
.queryString('jql', jqlQuery) | |
.queryString('maxResults', 0) // We only need the count, not the actual issues | |
.asObject(Map) | |
.body | |
fieldCounts[fieldId] = [ | |
name: fieldName, | |
type: fieldType, | |
count: searchResult.total | |
] | |
} | |
return fieldCounts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment