stderr:致命:不能执行' / tmp / ssh **。sh':权限被拒绝致命:无法分叉

时间:2018-03-02 17:54:05

标签: git jenkins github continuous-integration

我在尝试执行Jenkins工作时遇到错误。

git版本1.8.3.1 詹金斯2.46.2.1-滚动

我尝试将git升级到更高版本,但仍然通过跟随How to install latest version of git on CentOS 6.x/7.x链接挂起1.8.3.1。授予/ tmp权限也无法正常工作

我的RHEL7服务器来自AWS。

构建Jenkins作业时的错误日志 -

 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@git.devops.company.net:user/project_test.git # timeout=10
Fetching upstream changes from git@git.devops.company.net:user/project_test.git
 > git --version # timeout=10
using GIT_SSH to set credentials 
 > git fetch --tags --progress git@git.devops.company.net:user/project_test.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@git.devops.company.net:user/project_test.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
    at hudson.security.ACL.impersonate(ACL.java:260)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@git.devops.company.net:user/project_test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: cannot exec '/tmp/ssh2653538317929125933.sh': Permission denied
fatal: unable to fork

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1793)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1519)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
    at hudson.remoting.UserRequest.perform(UserRequest.java:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    at ......remote call to zz_server_IP(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:830)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
    at sun.reflect.GeneratedMethodAccessor1953.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
    at com.sun.proxy.$Proxy140.execute(Unknown Source)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:804)
    ... 13 more

1 个答案:

答案 0 :(得分:0)

Jenkins git客户端插件使用临时目录中的文件将凭据传递给命令行git。如果使用noexec选项挂载了选定的临时目录,则不允许命令行git从临时目录执行脚本。 git fetch将失败,并显示堆栈跟踪信息,因为命令行git没有收到所需的凭据。

自2.4.4起(2017年4月24日发布)的Git客户端插件版本尝试在Jenkins作业环境中使用临时目录。如果Jenkins作业环境不可用,则使用系统临时目录。

解决此问题的替代方法包括:

  • 在启动Jenkins的脚本(无论是/etc/init.d还是Windows或Shell脚本)中声明另一个系统临时目录:java -Djava.io.tmpdir=/path/to/tmpdir jenkins.war
  • 为Jenkins ssh代理声明一个不同的临时目录,作为在代理的“高级”部分中配置的JVM选项:-Djava.io.tmpdir=/path/to/tmpdir
  • 在启动JNLP代理的命令行上,将Jenkins JNLP代理的另一个临时目录声明为JVM选项:java -Djava.io.tmpdir=/path/to/tmpdir agent.jar -jnlpUrl http://jenkins.example.com:8080/computer/my-agent/slave-agent.jnlp -secret MY-SECRET
  • 在Jenkins git客户端插件中使用JGit implementation而不是命令行git
  • 不使用noexec选项安装系统临时文件系统