找不到SSH Shell命令(composer,npm)

时间:2019-03-11 17:35:04

标签: linux azure-devops whm

我的服务器是使用whm和cpanel在a2hosting上的Linux经销商计划。

我的项目是PHP Laravel。

在构建项目之后,使用Copy Files Over SSH任务,我能够将文件复制到服务器上。

问题是,当我尝试为SSHcomposer install添加npm install任务之后,出现错误。它使用与文件复制任务相同的SSH连接和密钥。 cdls之类的东西可以正常工作。

当我在本地使用相同的用户名和相同的私钥并运行composer install时,它和npm install一样有效。在运行composer和npm后,该站点可以很好地加载,但是我希望这可以自动化,因此我不必手动运行这些命令。

这是我的inline script

composer install

我的错误如下:

2019-03-11T16:34:21.4468896Z ##[section]Starting: Run Composer
2019-03-11T16:34:21.4471875Z ==============================================================================
2019-03-11T16:34:21.4472119Z Task         : SSH
2019-03-11T16:34:21.4472240Z Description  : Run shell commands or a script on a remote machine using SSH
2019-03-11T16:34:21.4472332Z Version      : 0.148.0
2019-03-11T16:34:21.4472433Z Author       : Microsoft Corporation
2019-03-11T16:34:21.4472519Z Help         : [More Information](http://go.microsoft.com/fwlink/?LinkId=821892)
2019-03-11T16:34:21.4472635Z ==============================================================================
2019-03-11T16:34:21.8985848Z composer install
2019-03-11T16:34:21.9008544Z Trying to establish an SSH connection to ***@mydomain.com:7822
2019-03-11T16:34:21.9181145Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9181767Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9182133Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9182449Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9183364Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9183731Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184084Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184417Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9184742Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185068Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185405Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9185751Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:21.9186053Z (node:1296) Warning: Use Cipheriv for counter mode of aes-256-ctr
2019-03-11T16:34:22.2806417Z Successfully connected.
2019-03-11T16:34:23.0424509Z tr -d '\015' <"./sshscript_1552322" > "./sshscript_1552322._unix"
2019-03-11T16:34:23.1378047Z chmod +x "./sshscript_1552322._unix"
2019-03-11T16:34:23.2240403Z "./sshscript_1552322._unix"
2019-03-11T16:34:23.3118392Z 
2019-03-11T16:34:23.3171367Z ##[error]./sshscript_1552322._unix: line 3: composer: command not found
2019-03-11T16:34:23.3180458Z 
2019-03-11T16:34:23.3181101Z ##[error]Command failed with errors on remote machine.
2019-03-11T16:34:23.4532093Z ##[section]Finishing: Run Composer

1 个答案:

答案 0 :(得分:0)

因为通过SSH手动登录时可以执行命令,但是不能通过Azure脚本执行相同的命令。这可能意味着您的管道脚本无法加载~/.bashrc或预期的$PATH值才能找到composer命令。您需要通过手动并通过管道脚本运行$PATH然后比较该值来确保管道脚本包含正确的echo $PATH值,然后比较该值,或者可以尝试放置composer的完整路径二进制文件,您可以通过执行which composer手动获取,npm