Jenkins 签出 GIT 项目失败,权限被拒绝致命:无法分叉

2023-12-19

我有一个 Freestyle Jenkins 项目,它使用 bitbucket 作为 SCM,使用 ssh 作为协议和私钥(不是用户/密码)。

当我在 master 上构建项目时,它失败并显示以下堆栈跟踪,而它在代理上运行良好。

注意错误提到:

stderr:致命:无法执行'/var/lib/jenkins/workspace/foo_test@tmp/ssh1377177620135545595.sh':权限被拒绝 致命:无法分叉

我检查了以下内容:

  • 从命令行以 jenkins 用户身份运行它显示没有问题。
  • Jenkins 可写入文件夹 /var/lib/jenkins/workspace/foo_test@tmp
  • 我正在使用最新版本Git 客户端 https://plugins.jenkins.io/git-client 2.7.4

可能是什么问题?

堆栈跟踪:

    Started by user unknown or anonymous
    Building on master in workspace /var/lib/jenkins/workspace/foo_test
    [WS-CLEANUP] Deleting project workspace...
    [WS-CLEANUP] Deferred wipeout is used...
    Cloning the remote Git repository
    Cloning repository ssh://[email protected] /cdn-cgi/l/email-protection:7999/~xxx/foo_poc.git
    > git init /var/lib/jenkins/workspace/foo_test # timeout=10
    Fetching upstream changes from ssh://[email protected] /cdn-cgi/l/email-protection:7999/~xxx/foo_poc.git
    > git --version # timeout=10
    using GIT_SSH to set credentials
     > git fetch --tags --progress ssh://[email protected] /cdn-cgi/l/email-protection:7999/~xxx/foo_poc.git +refs/heads/*:refs/remotes/origin/*
    ERROR: Error cloning remote repo 'origin'
    hudson.plugins.git.GitException: Command "git fetch --tags --progress ssh://[email protected] /cdn-cgi/l/email-protection:7999/~xxx/foo_poc.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
    stdout:
    stderr: fatal: cannot exec '/var/lib/jenkins/workspace/foo_test@tmp/ssh1377177620135545595.sh': Permission denied
    fatal: unable to fork
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2016)
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1735)
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:420)
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:629)
            at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1146)
            at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
            at hudson.scm.SCM.checkout(SCM.java:504)
            at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
            at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
            at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
            at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
            at hudson.model.Run.execute(Run.java:1819)
            at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
            at hudson.model.ResourceController.execute(ResourceController.java:97)
            at hudson.model.Executor.run(Executor.java:429)
    ERROR: Error cloning remote repo 'origin'
    Finished: FAILURE

检查主服务器上的工作区目录是否未使用“noexec”选项挂载。

  • 查看 /etc/fstsab 以查找这些设置
  • 删除 noexec
  • 重启机器

有关更多信息,请参阅 Mark Waiter 的精彩回答

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

Jenkins 签出 GIT 项目失败,权限被拒绝致命:无法分叉 的相关文章

随机推荐