gpt4 book ai didi

windows - Windows 上的 Jenkins 与 Docker - 无法运行程序 "nohup"

转载 作者:行者123 更新时间:2023-12-02 22:49:18 24 4
gpt4 key购买 nike

我正在将 Jenkins Azure VM Agents Plugin 与 Linux Master 结合使用,在 Windows 代理上启 Action 业。

我已经完成了所有配置步骤,一切正常,直到我尝试在代理上使用 Docker。

我的管道脚本:

pipeline {
agent {
docker {
image 'myurl.io/myimage:latest'
registryUrl 'https://myurl.io/'
registryCredentialsId '123456789abcdefg'
}
}

管道在运行此命令时似乎失败:

docker pull myurl.io/myimage:latest

报告的错误归结为:

Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Jenkins\workspace\Test Pipeline Docker"): CreateProcess error=2, The system cannot find the file specified

一些注意事项:

  • 我已勾选在镜像上安装 git 的框: enter image description here

  • Git 工具似乎已成功安装在代理虚拟机上

  • This question 似乎相关,但不是完全相同

    • 我没有直接运行 sh 命令,它是由插件运行的。
    • 我认为现阶段我无权设置 PATH
  • JIRA https://issues.jenkins-ci.org/browse/JENKINS-36776 上的这个问题是相关的,但它似乎没有得到解决,并且建议的解决方法似乎不适用于我的情况

我的问题

有没有办法让我的管道脚本正常工作?也许我可以在代理启动后(但在 docker pull 命令之前)以某种方式在代理上执行一些额外的命令,以将所需的目录添加到 PATH 中?

或者还有其他解决方法吗?

最佳答案

我认为您已经找到的问题是正确的: Jenkins pipeline sh fail with "cannot run program nohup" on windows

但是,根据 docker-pipeline 插件的 wiki 页面,不支持在 Windows Worker 上运行 docker(虽然有点隐藏......):

For Jenkins environments which have macOS, Windows, or other agents, which are unable to run the Docker daemon, this default setting may be problematic. [https://www.jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label]

据我所知,已经多次尝试添加该功能,但似乎尚未添加:https://github.com/jenkinsci/docker-workflow-plugin/pull/148

在最后一个链接中还指出,修复 sh/nohup 问题并不是您唯一的问题,例如 docker 插件将尝试运行 id 来获取用户。

尽管如此,您可以尝试通过编辑管道声明中的路径来使 Linux 命令可用: https://stackoverflow.com/a/45101214/12338776

编辑:刚看到这个问题已经3年了……好吧。但由于到目前为止还没有答案,而且很多人似乎仍然到达这里,它可能仍然对某人有帮助。

关于windows - Windows 上的 Jenkins 与 Docker - 无法运行程序 "nohup",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49305031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com