Jenkins 在 ssh 命令中分配变量
Jenkins assign variable in ssh command
我在环境部分声明了变量日志文件,并试图在远程系统中执行 ls -t -c1 *.log | head -1
命令后为其赋值。
我知道我做错了way.Any想法如何在远程系统中执行命令后分配变量值?
您可以通过以下方式在变量中获取 return 值:
# Declare variable init
def logResult
logResult = sshCommand remote: remote, command: "ls -t -c1 *.log | head -1"
您可以在脚本中使用它:
script {
test = sh(script "echo ${logResult}")
}
我在环境部分声明了变量日志文件,并试图在远程系统中执行 ls -t -c1 *.log | head -1
命令后为其赋值。
我知道我做错了way.Any想法如何在远程系统中执行命令后分配变量值?
您可以通过以下方式在变量中获取 return 值:
# Declare variable init
def logResult
logResult = sshCommand remote: remote, command: "ls -t -c1 *.log | head -1"
您可以在脚本中使用它:
script {
test = sh(script "echo ${logResult}")
}