// Call the Jira REST API to retrieve all projects
def response = get('/rest/api/3/project')
.header('Content-Type', 'application/json')
.asObject(List)
// Check for a successful response
if (response.status != 200) {
return "Error fetching projects: ${response.status} - ${response.statusText}"
}
// Cast the response body to a List of Maps for static type checking
List<Map> projects = response.body as List<Map>
// Extract project data and map to a simplified structure
return projects.collect { project ->
[
id : project['id'],
key : project['key'],
name : project['name']
]
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter