使用Jenkins 启动shell脚本所遇到的问题

2023-05-16

sh命令无法使用:


Building in workspace C:\Program Files (x86)\Jenkins\workspace\test
[test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh
The system cannot find the file specified

FATAL: L'exécution de la commande a échoué.
java.io.IOException: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\test"): CreateProcess error=2, Le fichier spécifié est introuvable
    at java.lang.ProcessBuilder.start(Unknown Source)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
    at hudson.Launcher$ProcStarter.start(Launcher.java:382)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1744)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 16 more
Build step 'Exécuter un script shell' marked build as failure
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Finished: FAILURE

As far as I know, Windows will not support shell scripts out of the box. You can install Cygwin or Git for Windows, go to Manage Jenkins > Configure System Shell and point it to the location of sh.exe file found in their installation. For example:

C:\Program Files\Git\bin\sh.exe

There is another option I've discovered. This one is better because it allowed me to use shell in pipeline scripts with simple sh "something".

Add the folder to system PATH. Right click on Computer, click properties > advanced system settings > environmental variables, add C:\Program Files\Git\bin\ to your system Path property.

IMPORTANT note: for some reason I had to add it to the system wide Path, adding to user Path didn't work, even though Jenkins was running on this user.

Disclaimer: the names may differ slightly as I'm not using English Windows.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用Jenkins 启动shell脚本所遇到的问题 的相关文章

  • 如何在bash中仅提取两个字符串之间多行的第一个实例?

    我的文件是 abc 123 xyz abc 675 xyz 我想提取 abc 123 xyz 123 可以是任何东西 重点是我想要第一次出现 我尝试使用这个 sed n abc xyz p filename 但这给了我所有的例子 我怎样才能
  • 从 bash 脚本运行节点

    很简单 我正在尝试使用 cron 自动运行 nodejs 脚本 但是脚本本身似乎无法运行该文件 我的脚本很简单 usr bin env node node var node assets js update js 但是 在运行此命令时 它返
  • 使用脚本自动输入 SSH 密码

    我需要创建一个自动向 OpenSSH 输入密码的脚本ssh client 假设我需要通过 SSH 进入myname somehost用密码a1234b 我已经尝试过 bin myssh sh ssh myname somehost a123
  • 向伪 shell (pty) 发出命令

    我尝试使用 subprocess popen os spawn 来运行进程 但似乎需要伪终端 import pty master slave pty openpty os write master ls l 应该发送 ls l 到从属终端
  • 在 Cloudbees Jenkins 文件夹中设置环境变量

    在我重新安装 Jenkins 和 Cloudbees Free Enterprise 插件后 Jenkins 文件夹中设置的环境变量停止工作并从配置 UI 中消失 但是 它仍然存在于文件系统上的 config xml 中 如下所示
  • 如何从 Linux 的 shell 中删除所有以 ._ 开头的文件?

    确实如标题所示 我已将许多文件从 Mac 复制到 Raspberry Pi 这导致了许多以前缀开头的多余文件 我想删除以以下开头的文件夹中的每个文件 我该怎么做 尝试类似的方法 cd path to directory rm rf 或者 如
  • macOS 更新后 Jenkins 用户消失

    我在 Mac 上运行 Jenkins 作为 CI 服务器 使用用户 jenkins 的典型设置 它在 macOS 10 12 上运行良好 今天我将 macOS 升级到 10 13 High Sierra 升级过程完成后 Jenkins 无法
  • 列出破折号中当前定义的函数?

    我想列出当前定义的函数dash 有什么办法可以做到这一点吗 我能想到的最接近的是type它可以用来测试一个函数是否存在 但除此之外我很困惑 附 我说的是dash在这里 不是bash or zsh 看看 exec c 似乎没有 没有 表是静态
  • 如何使用AWK脚本检查表的所有列数据类型? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 在这里 我正在检查表中第一列的数据类型 但我想知道AWK中表的所有列数据类型 我尝试过 但只能获得一列数据类型 例如 Column 1
  • Powershell Invoke-Command 远程手动工作,但不能通过 Jenkins

    我遇到了一个非常奇怪的情况 即从 Windows Server 2012 R2 手动运行相同的命令时可以工作 但从同一服务器上运行的 Jenkins 从属进程无法工作 首先 手动运行的输出 管理 PowerShell 窗口 PS C Use
  • 在 Fish Shell 中设置导出

    我安装了多个版本的 PHP 对于我的正常开发 我总是使用通过自制程序安装的 PHP 5 5 x 在鱼壳里 which php php version gt usr local bin php gt PHP 5 5 8 cli built J
  • Apache 反向代理的基本身份验证问题

    我想为在 Ubuntu 服务器 12 04 1 上运行的 Apache 反向代理站点添加基本身份验证 网络应用程序是Jenkins http jenkins ci org运行在 Java EE 容器上 我在中添加了以下配置httpd con
  • 如何在 Jenkins 中安排构建?

    如何安排 Jenkins 构建 使其只能在每天的特定时间进行构建 例如下午 4 点开始 0 16 1 7 我理解为 每个月周一到周日下午 0 分钟 下午 4 点 但是它每分钟都会构建 如果有任何建议 我将不胜感激 谢谢 Update 请阅读
  • Jenkins:在管道 Jenkins 文件内执行 AWS CLI 命令

    您知道如何在 aws 中执行 AWS CLI 命令吗 Jenkinsfile为了建立管道 我没有找到任何插件 首先 您需要在服务器上安装 aws cli 并确保 jenkins 用户有权运行它 或者在创建 EC2 实例时简单地使用 Amaz
  • 仅当重复行与模式匹配时才删除它们

    这个问题 https stackoverflow com questions 1444406 how can i delete duplicate lines in a file in unix有一个很好的答案说你可以使用awk seen
  • 在 bash 中使用单个命令为 shell 变量分配默认值

    我对 bash 3 00 shell 脚本中的变量进行了大量测试 如果未设置变量 则它会分配默认值 例如 if z VARIABLE then FOO default else FOO VARIABLE fi 我似乎记得有一些语法可以在一行
  • 使用 posix shell 测试字符串中的正则表达式

    如何测试字符串是否与特定字符串匹配正则表达式与基本 无 bash 或任何其他 posix shell 脚本 在 if 语句中 您可以使用expr在 POSIX shell 中计算正则表达式的命令 s Abc expr s alpha 3 e
  • Jenkins:尽管没有变化,SCM 仍然触发持续构建

    我们遇到一个问题 尽管没有代码更改 SCM 仍在触发构建 SCM 每 15 分钟轮询一次更改 并且仅在发现更改时才触发构建 以下是连续 SCM 轮询日志的几个示例 Started on Nov 15 2013 11 47 14 AM Usi
  • Jenkins 和 Github 不使用 SSH 密钥

    我已将 Jenkins 设置为从 Github 上的私有存储库中提取特定作业 尽管我已经生成了私钥 公钥并将其作为部署密钥添加到 github 但 Jenkins 似乎并未使用 SSH 密钥 当我从 Jenkins 用户进行 git clo
  • 如何执行“sudo nvm”?

    在我的 Mac 上 我想将一些需要 su 权限的包迁移到另一个节点版本 我使用 homebrew 安装 nvm 现在我需要执行 sudo nvm 或 reinstall packages将失败 me MacBook sudo nvm sud

随机推荐