Using Helm cli in a groovy script in an extendedChoice

Hi Jenkins community,

I would like to use the Helm cli in an extendedChoice to get all versions of a Helm chart and use them in a dropdown menue as input variables in my pipeline. I have googled for many hours but haven’t found anything regarding it (using Helm inside my container is not the problem). If the Helm cli would be usable it could be used with the following code in an extendedChoice:

parameters {
     name: 'HELM_VERSION',
     description: 'Select the example operator Helm chart version',
     type: 'PT_SINGLE_SELECT',
     groovyScript: """
             try {
                     def command = '''
                     helm repo add helm-chart-repo 1> /dev/null
                     helm repo update 1> /dev/null
                     helm search repo helm-chart-repo/example-operator --versions 2> /dev/null | cut -f2  | grep -v CHART
                     def p = ['bash', '-c', command].execute()

                     return p.getText().normalize().readLines()
             }catch(Exception e) {
                     print "There was a problem fetching Helm repository" + e

Thanks for your help!