【问题标题】:Jenkins - Publish Over SSH - EXEC: STDOUT/STDERR - bash: service: command not found詹金斯 - 通过 SSH 发布 - 执行:STDOUT/STDERR - bash:服务:找不到命令
【发布时间】:2017-05-05 08:39:52
【问题描述】:

我对 Publish Over SSH 插件有疑问,并且已经尝试了很多可能的解决方案,但仍然不起作用:

  1. 在 pty 中使用 exec
  2. 使用 bash --login
  3. 使用 shebang (#!/usr/bin/env bash)

执行脚本

service monitoring-daemon stop
cd /home/push/monitoring/target
rm -rf Monitoring.jar
ls -la | grep Monitoring | grep -v grep | awk '{print $9}' | xargs -I file mv file Monitoring.jar
service monitoring-daemon start

控制台输出

    10:26:25 SSH: EXEC: STDOUT/STDERR from command [service monitoring-daemon stop
    10:26:25 cd /home/push/monitoring/target
    10:26:25 rm -rf Monitoring.jar
    10:26:25 ls -la | grep Monitoring | grep -v grep | awk '{print $9}' | xargs -I file mv file Monitoring.jar
    10:26:25 service monitoring-daemon start] ...
    10:26:25 SSH: EXEC: connected
    10:26:25 bash: service: command not found
    10:26:25 bash: line 4: service: command not found
    10:26:25 SSH: EXEC: completed after 201 ms
    10:26:25 SSH: Disconnecting configuration [*********] ...
    10:26:25 ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [127]]
    10:26:25 Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE
    10:26:25 [ANALYSIS-COLLECTOR] Computing warning deltas based on reference build #48

我的 Jenkins 使用 bash 作为默认 shell,远程服务器也使用 bash。

远程服务器 .bashrc

# .bashrc
alias service='/sbin/service'
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions

远程服务器 .bash_profile

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH

我是否缺少任何配置或步骤?

【问题讨论】:

    标签: bash jenkins ssh exec


    【解决方案1】:

    尝试为“服务”放置完整路径,即.. 将“服务”替换为“/usr/sbin/service”

    添加如下所示的第一行也可能有助于设置路径 . /etc/profile

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-15
      相关资源
      最近更新 更多