jenkins默认是用非登录模式来执行shell命令,所有没有加载环境变量配置文件。

source /etc/profile

可以如下修改:
jenkin执行shell脚本,找不到命令
添加source /etc/profile
缺点:这样的话控制台的输出会有很多无用的日志信息。
jenkin执行shell脚本,找不到命令

# !/bin/sh -l

还有更优雅的方式是让jenkins以登录的模式来执行shell脚本。
jenkin执行shell脚本,找不到命令
添加#!/bin/sh -l(在#和!之间不能有空格)
控制台日志:
jenkin执行shell脚本,找不到命令
很简洁,没有无用的信息。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-09-24
  • 2021-10-06
  • 2021-12-04
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2021-10-28
  • 2021-10-16
  • 2021-06-24
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案