Store mysql output from shell script into a variable

  Kiến thức lập trình

I have the following block of code:

def queryResult = sh(script: """
            mysql -u ${username} -p${password} --host=${host} --port=${port} --ssl-ca=${cert} --database=${db} --execute="SELECT * FROM my_table WHERE source='janeDoe'"

I expect it would print out the result of the mysql query. However, it always prints queryResult:null.

I tried this solution but it ended in the same output.

Any help is appreciated.