我正在尝试使用 groovy 脚本在活动的 Active Choices 参数中呈现从 shell 获得的信息。我可以使用 sh 方法从 jenkins 管道中的 groovy 脚本轻松访问 shell,如下所示:
node()
{
sh 'git log ...'
}
但是,当我在 Active 选择的 groovy 脚本中尝试此操作时,它会崩溃并执行回退脚本。
是否可以在此上下文中切换到节点并执行 shell 命令?
谢谢您的帮助!
我正在尝试使用 groovy 脚本在活动的 Active Choices 参数中呈现从 shell 获得的信息。我可以使用 sh 方法从 jenkins 管道中的 groovy 脚本轻松访问 shell,如下所示:
node()
{
sh 'git log ...'
}
但是,当我在 Active 选择的 groovy 脚本中尝试此操作时,它会崩溃并执行回退脚本。
是否可以在此上下文中切换到节点并执行 shell 命令?
谢谢您的帮助!
这是使用主动选择插件的示例片段。
def command = $/aws ec2 describe-instances \
--filters Name=tag:Name,Values=Test \
--query Reservations[*].Instances[*].PrivateIpAddress \
--output text /$
def proc = command.execute()
proc.waitFor()
def output = proc.in.text
def exitcode= proc.exitValue()
def error = proc.err.text
if (error) {
println "Std Err: ${error}"
println "Process exit code: ${exitcode}"
return exitcode
}
//println output.split()
return output.tokenize()