Hi,
I got this sample from here, https://scriptrunner.adaptavist.com/4.3.5/jira/behaviours-conversions.html
Code snippet from the url :
def repoNames = repos["items"]*."full_name"
rt = [
items: repoNames.collect { String repo ->
[
value: repo,
html : repo.replaceAll(/(?i)$query/) { "<b>${it}</b>" },
label: repo,
]
},
total: repos["total_count"],
footer: "Choose repo... (${repoNames.size()} of ${repos["total_count"]} shown...)"
]
Json:
"id": 76954504, "node_id": "MDEwOlJlcG9zaXRvcnk3Njk1NDUwNA==", "name": "react-tetris", "full_name": "chvin/react-tetris", "private": false, "owner": {
As you can see it's getting the "full_name" but I want to combine let say "full_name" and "node_id". So the output would look like "chvin/react-tetris MDEwOlJlcG9zaXRvcnk3Njk1NDUwNA==" Does anyone know how I can achieve this from the code?
Thanks!
This line does an implicit collection of all the "full_name" from all the items (that's what the * does).
def repoNames = repos["items"]*."full_name"
So instead, just do your own collection:
def repoNames = repos["items"].collect{"${it."full_name"} ${it."node_id"}"}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.