Jenkins shell 脚本中没有这样的文件或目录错误,在其他工作中运行良好 [英] No such file or directory error in Jenkins shell script that works well in another jobs

查看:79
本文介绍了Jenkins shell 脚本中没有这样的文件或目录错误,在其他工作中运行良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个 Jenkins 实例中有四个不同但非常相似的作业,并且使用相同的用户运行,它们具有相同的 shell 步骤定义.shell 步骤定义是这样的:

I have four different but very similar jobs in the same Jenkins instance and ran with the same user, that have the same shell step definition. The shell step definition is like this:

#!/bin/sh
  echo $WORKSPACE
  cd $JENKINS_HOME/users/foo
  sh script.sh

当我执行作业时,它抛出下一个错误:

When I execute the job, it throws the next error:

cd:/var/lib/jenkins/users/foo: 没有那个文件或目录

cd: /var/lib/jenkins/users/foo: No such file or directory

sh: script.sh: 没有那个文件或目录

sh: script.sh: No such file or directory

在我在 shell 步骤中具有相同命令序列的其他作业中,它运行良好并且 script.sh 被执行.

In the other jobs that I have the same command sequence in the shell step, it works well and the script.sh is executed.

我看了几篇帖子,尝试改成bin/bash,直接用source./执行脚本,但没有一个解决方案有效.

I have seen several posts and I have tried to change to bin/bash, execute the script directly with source or ./, but none of the solutions worked.

推荐答案

我已经找到了解决方案.问题是在slave节点执行了失败的job,在slave节点,在$JENKINS_HOME文件夹下做一个ls,根本就没有/users/foo文件夹.

I have already found the solution. The problem was that the failed job was being executed in the slave node, and in the slave node, making a ls in the $JENKINS_HOME folder, there was no /users/foo folder at all.

因此,我已标记我失败的作业在主节点而不是从节点中运行.我再次执行了这项工作,现在效果很好.

So, I have marked that my failed job ran in the principal node instead of the slave node. I have executed the job again and now it works well.

问题,其实就是Jenkins服务器的principal和slave节点没有正确同步.

The problem, in fact, was that the principal and slave nodes in Jenkins server weren't synchronized correctly.

这篇关于Jenkins shell 脚本中没有这样的文件或目录错误,在其他工作中运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆