gpt4 book ai didi

jenkins - 从 Jenkins 管道获取 ssh-steps 输出

转载 作者:行者123 更新时间:2023-12-04 00:02:11 27 4
gpt4 key购买 nike

我对 Jenkins 很陌生,所以也许问题很明显。

我在 Windows 机器上有 Jenkins,我需要在远程 nix 机器上运行命令,在那里我有 ssh 访问权限(通过用户名/密码)。我有一个管道,并且使用 ssh-steps 插件作为管道我可以连接和执行命令,但是我需要获得命令的输出才能继续前进,但我找不到正确的方法来做到这一点。

def remote = [:]
remote.name = 'UAT'
remote.host = 'test.domain'
remote.user = 'username'
remote.password = 'pass'
remote.allowAnyHosts = true
stage('Remote SSH') {
sshCommand remote: remote, command: "ls -ll"
}

是否可以使用此插件来实现,或者我需要使用另一个插件?据我了解,这个插件是专门为在管道脚本中使用 ssh 而创建的。

最佳答案

试试这个:

def remote = [:]
remote.name = 'UAT'
remote.host = 'test.domain'
remote.user = 'username'
remote.password = 'pass'
remote.allowAnyHosts = true
stage('Remote SSH') {
def commandResult = sshCommand remote: remote, command: "ls -ll"
echo "Result: " + commandResult
}

这不容易弄清楚,因为没有记录!

关于jenkins - 从 Jenkins 管道获取 ssh-steps 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59028788/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com