'How to execute shell script in jenkins Active Choice Parameter so that I can get the dynamic inputs

I tried fetching present working directory using below script in Active Choice Parameter in Jenkins but it's not giving any output. Also the fallback script is not getting called

def command = "pwd"
def proc = command.execute()
proc.waitFor()              
def output = proc.in.text
def exitcode = proc.exitValue()
def error = proc.err.text
println "${output}"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source