I declared the variable logfile in the environment part and was trying to assign its value after executing ls -t -c1 *.log | head -1
command in the remote system.
I know i am doing it the wrong way.Any ideas how to assign the variable value after executing command in the remote system?
You can take return value in a variable in below way :
# Declare variable init
def logResult
logResult = sshCommand remote: remote, command: "ls -t -c1 *.log | head -1"
You can use it in script as:
script {
test = sh(script "echo ${logResult}")
}