You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

初次Jenkins构建在Git Clone阶段失败,错误代码13求助

Jenkins Git Clone 错误代码#13(Permission Denied)解决指南

Hey there, let's fix that frustrating Git clone error you're hitting with Jenkins. The error code #13 and "Permission denied" message spell out the core issue: the Jenkins user doesn't have the right permissions to execute the Git tool located at /var/lib/jenkins/tools/git. Here's how to resolve this step by step:

1. First, check the Git tool's permissions

Log into your Jenkins server and run this command to inspect the permissions of the Git executable Jenkins is trying to use:

ls -l /var/lib/jenkins/tools/git

You'll see output like this—focus on the owner and permission bits:

-rwxr-xr-x 1 root root 145200 Aug 15 09:30 /var/lib/jenkins/tools/git

If the owner is root instead of jenkins, that's the root cause. Jenkins runs under the jenkins user account, so it can't execute files owned by root without proper access.

2. Fix ownership and execution permissions

Run these two commands to transfer ownership of the Git tool to the jenkins user and ensure it's executable:

sudo chown jenkins:jenkins /var/lib/jenkins/tools/git
sudo chmod +x /var/lib/jenkins/tools/git

The first command gives the jenkins user full ownership of the file, and the second adds explicit execution permissions.

3. Verify Jenkins' Git configuration

Head to your Jenkins web dashboard, go to Manage Jenkins → Global Tool Configuration, and find the Git section. Double-check that the "Path to Git executable" is set to /var/lib/jenkins/tools/git—a misconfigured path here could also trigger permission issues.

4. Test permissions as the Jenkins user (if needed)

If the above steps don't work, switch to the jenkins user and test running Git manually to confirm the fix:

sudo su jenkins
/var/lib/jenkins/tools/git --version

If you still get a permission error here, the problem might lie with the parent directory (/var/lib/jenkins/tools). Fix that with:

sudo chown -R jenkins:jenkins /var/lib/jenkins/tools
sudo chmod -R 755 /var/lib/jenkins/tools

That should do it! Most of the time, adjusting the Git executable's ownership and permissions resolves this #13 error immediately—Jenkins just needs the right access to run the tool.

内容的提问来源于stack exchange,提问作者camto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 14:37:29