Reputation: 147
I am trying to use active choice parameters in jenkins . I am executing a shell command and trying to show the output in the choice parameters. 1) Working scenario -
Text file already generated by the output of shell command and able to see the parameters -
list = []
def process = "cat /home/ansible/test1.txt".execute()
process.text.eachLine {list.add it}
return list
Here test1.txt is already populated with the values
2) Failure scenario Instead of pre-populating the file trying the get the shell command output and write into a file and then show it to the choice parameters-
list = []
def process1=" sh script.sh > test1.txt".execute()
def process = "cat /home/ansible/test1.txt".execute()
process.text.eachLine {list.add it}
return list
This is not working
Is there any suggestions ?
Upvotes: 0
Views: 1011
Reputation: 28564
Use pure groovy to read file lines
new File('/home/ansible/test1.txt').readLines()
For your case - wrap your code with try-catch to see the error.
Without error message it's hard to help you...
try{
def list ....
}catch(e){ return [e.toString()] }
Upvotes: 1