我有一个 Jenkins 工作任务,其中 "Execute shell" 下有以下命令:
ssh jenkins@172.31.12.58
pwd
我希望Jenkins服务器能够通过SSH连接到远程服务器,并在远程服务器上运行命令。
但实际上,Jenkins只是连接到了远程服务器,然后立即断开连接,在本地运行pwd
命令,如下面的输出所示:
Started by user Johanan Lieberman
Building in workspace /var/lib/jenkins/jobs/Test Github build/workspace
[workspace] $ /bin/sh -xe /tmp/hudson266272646442487328.sh
+ ssh jenkins@172.31.12.58
Pseudo-terminal will not be allocated because stdin is not a terminal.
+ pwd
/var/lib/jenkins/jobs/Test Github build/workspace
Finished: SUCCESS
编辑: 你知道为什么在ssh
命令之后的其他命令没有在SSH shell中运行,而是在本地运行吗?