git 詹金斯无法获取回购 - 代码 255 权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30535422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins unable to fetch repo - code 255 permission denied
提问by Samsquanch
I'm trying to set up Jenkins to work with git webhooks. So far I have
我正在尝试设置 Jenkins 以使用 git webhooks。到目前为止我有
- Jenkins running
- Created an ssh key pair under the
jenkins
user - Added the key to git deploy keys
- Added the git plugin
- Configured the project to use git with the repo
- Set the branch to
*/develop
to only watch the dev branch - Set the custom workspace directory to
/data/www/<site>
- Added the
ubunutu
group to thejenkins
user (see below)
- 詹金斯跑步
- 在
jenkins
用户下创建了ssh密钥对 - 将密钥添加到 git deploy 密钥
- 添加了 git 插件
- 将项目配置为将 git 与 repo 一起使用
- 将分支设置
*/develop
为仅监视 dev 分支 - 将自定义工作区目录设置为
/data/www/<site>
- 将
ubunutu
组添加到jenkins
用户(见下文)
And when trying to build the project, I get this error:
在尝试构建项目时,我收到此错误:
Started by user anonymous
Building in workspace /data/www/<site>
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.jenkins.url [email protected]:<repo_url> # timeout=10
ERROR: Error fetching remote repo 'jenkins'
hudson.plugins.git.GitException: Failed to fetch from [email protected]:<repo_url>
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
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: hudson.plugins.git.GitException: Command "git config remote.jenkins.url [email protected]:<repo_url>" returned status code 255:
stdout:
stderr: error: could not lock config file .git/config: Permission denied
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1591)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1567)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1563)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1249)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1261)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:961)
at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:160)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:723)
... 11 more
ERROR: Error fetching remote repo 'jenkins'
The repo has already been pulled by a different user (in this case, ubuntu:ubuntu
) in the /data/www/<site>
directory, so initially I thought adding the ubunutu
group to jenkins
would fix the problem, but no luck. I've also tried logging in as the jenkins
user and pulling the repo, which I can do successfully.
该存储库已被目录中的其他用户(在本例中为ubuntu:ubuntu
)拉取/data/www/<site>
,因此最初我认为将ubunutu
组添加到jenkins
可以解决问题,但没有运气。我也试过以jenkins
用户身份登录并拉取 repo,我可以成功地做到这一点。
I've tried googling everything I can think of, but most searches point to people who are having key problems, rather than config file permission problems. At this point I'm out of ideas.
我试过在谷歌上搜索我能想到的所有内容,但大多数搜索都指向遇到关键问题的人,而不是配置文件权限问题。在这一点上,我没有想法。
Edit:
编辑:
ls -la
in the .git
dir:
ls -la
在.git
目录中:
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 5 12:13 branches
-rw-rw-r-- 1 ubuntu ubuntu 15 Mar 5 18:09 COMMIT_EDITMSG
-rw-rw-r-- 1 jenkins jenkins 318 Jun 1 14:55 config
-rw-rw-r-- 1 ubuntu ubuntu 73 Mar 5 12:13 description
-rw-rw-r-- 1 ubuntu ubuntu 88 May 29 12:50 FETCH_HEAD
-rw-rw-r-- 1 ubuntu ubuntu 24 May 28 13:21 HEAD
drwxrwxr-x 2 ubuntu ubuntu 4096 May 28 13:49 hooks
-rw-rw-r-- 1 ubuntu ubuntu 36480 May 29 12:50 index
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 5 12:13 info
drwxrwxr-x 3 ubuntu ubuntu 4096 Mar 5 12:13 logs
drwxrwxr-x 260 ubuntu ubuntu 4096 Apr 10 10:40 objects
-rw-rw-r-- 1 jenkins jenkins 41 May 29 11:53 ORIG_HEAD
-rw-rw-r-- 1 ubuntu ubuntu 179 Mar 5 12:13 packed-refs
drwxrwxr-x 5 ubuntu ubuntu 4096 Mar 5 12:13 refs
ls -la
from the parent dir (it's a Laravel 5 app):
ls -la
从父目录(这是一个 Laravel 5 应用程序):
drwxrwxr-x 13 ubuntu ubuntu 4096 Apr 3 11:07 app
-rwxrwxr-x 1 ubuntu ubuntu 2452 Mar 5 12:13 artisan
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 11 08:18 bootstrap
-rwxrwxr-x 1 ubuntu ubuntu 1094 Mar 11 08:16 composer.json
-rw-rw-r-- 1 ubuntu ubuntu 79004 Mar 11 08:17 composer.lock
-rwxrwxr-x 1 ubuntu ubuntu 146 Mar 5 12:13 CONTRIBUTING.md
drwxrwxr-x 8 ubuntu ubuntu 4096 May 6 09:45 frontend
drwxrwxr-x 8 ubuntu ubuntu 4096 Jun 1 14:56 .git
-rwxrwxr-x 1 ubuntu ubuntu 12 Mar 5 12:13 .gitattributes
-rwxrwxr-x 1 ubuntu ubuntu 160 Mar 5 12:13 .gitignore
-rwxrwxr-x 1 ubuntu ubuntu 567 Mar 5 12:13 phpunit.xml
drwxrwxr-x 7 www-data www-data 4096 Mar 5 17:13 public
-rwxrwxr-x 1 ubuntu ubuntu 2051 Mar 5 12:13 readme.md
-rwxrwxr-x 1 ubuntu ubuntu 519 Mar 5 12:13 server.php
drwxrwxr-x 29 ubuntu ubuntu 4096 Mar 11 08:18 vendor
Groups:
团体:
$ cat /etc/group | grep jenkins
ubuntu:x:1000:jenkins
jenkins:x:113:
$ cat /etc/group | grep ubuntu
adm:x:4:syslog,ubuntu
dialout:x:20:ubuntu
cdrom:x:24:ubuntu
floppy:x:25:ubuntu
sudo:x:27:ubuntu
audio:x:29:ubuntu
dip:x:30:ubuntu
video:x:44:ubuntu
plugdev:x:46:ubuntu
netdev:x:102:ubuntu
ubuntu:x:1000:jenkins
回答by gvsrepins
This works pretty nice form me:
这对我来说非常有效:
1 - Find the git config.lock
file, inside the jenkinsfolder run:
1 -config.lock
在jenkins文件夹中找到 git文件,运行:
find . -type f -name "config.lock"
find . -type f -name "config.lock"
2 - Delete the config.lock
file founded.
2 - 删除建立的config.lock
文件。
Thats it!
就是这样!
回答by cecukemon
Check the owner / permissions of the .git/config file in the jenkins workspace. It's probably still owned by the ubuntu user. Change the owner to the jenkins user.
检查 jenkins 工作区中 .git/config 文件的所有者/权限。它可能仍然归 ubuntu 用户所有。将所有者更改为 jenkins 用户。
回答by RPresle
Maybe you've already looked at it but I found a forum postwhere links were given to tickets. Go through them, you may find something.
也许您已经看过它,但我发现了一个论坛帖子,其中提供了门票的链接。通过它们,你可能会发现一些东西。
Citing :
引用:
- JENKINS-21914- matches your error message, but I can't duplicate it
- JENKINS-21376- different error message, but related to lock file
- JENKINS-24179- different error message
- JENKINS-25353- lingering lock file (not likely related to this one)
- JENKINS-21914- 匹配您的错误消息,但我无法复制它
- JENKINS-21376- 不同的错误消息,但与锁定文件有关
- JENKINS-24179- 不同的错误消息
- JENKINS-25353- 延迟锁定文件(可能与此无关)
More relevent listed errors are :
更多相关列出的错误是:
.git\config.lock
needs to be deleted- Need
git-client-plugin
version 1.6.2 at least
.git\config.lock
需要删除git-client-plugin
至少需要1.6.2 版本
回答by javabrett
In order to troubleshoot this, you should login as or su to the jenkins
user (with the assurance that Jenkins is running as jenkins
), using the same environment the Jenkins service is running with, then cd /data/www/<site>/.git
then ls -als config.lock
and touch config.lock
. This is the file Git is having trouble creating - these commands will check whether it already exists, and if not, whether the jenkins
user can create it.
为了解决这个问题,您应该使用 as 或 su 登录到jenkins
用户(确保 Jenkins 运行为jenkins
),使用Jenkins 服务运行的相同环境,cd /data/www/<site>/.git
然后ls -als config.lock
和touch config.lock
。这是 Git 创建时遇到问题的文件 - 这些命令将检查它是否已经存在,如果不存在,则jenkins
用户是否可以创建它。
As unlikely as it seems, the most likely problem is that you need to restart some things or reboot, because new group-membership permissions are not applied to existing processes or their children. Have you restarted Jenkins? If not, stop Jenkins, and depending on how it is launched - you need a fresh shell - relaunch it Reboot the server if you need to be really sure.
尽管看起来不太可能,但最可能的问题是您需要重新启动某些东西或重新启动,因为新的组成员权限不适用于现有进程或其子进程。你有没有重新启动詹金斯?如果没有,请停止 Jenkins,并根据它的启动方式 - 您需要一个新的 shell - 重新启动它 如果您需要非常确定,请重新启动服务器。
Also please report your filesystem type and mount options.
另外请报告您的文件系统类型和挂载选项。
回答by Samoilenko Yuri
There is a bug in rubygems/installer.rb
rubygems/installer.rb 中有一个错误
Use gem update --system
to update rubygems to lastest stable version that fixes this issue.
用于gem update --system
将 rubygems 更新到修复此问题的最新稳定版本。
回答by Arpit Aggarwal
Got the same issue after Jenkins
machine got restarted, fixed it updating the credentials for proxy in .gitconfig
along with deleting the job folder from Jenkins workspace, as follows:
Jenkins
机器重新启动后遇到同样的问题,修复它更新代理凭据.gitconfig
以及从 Jenkins 工作区中删除作业文件夹,如下所示:
$ cat ~/.gitconfig
Updating below as:
更新如下:
[http]
proxy = http://username:[email protected]:80
sslverify = false
[https]
proxy = http://username:[email protected]:80
sslverify = false
[url "http://github.com/"]
insteadOf = git://github.com/
[user]
name = Arpit Aggarwal
email = [email protected]
[core]
autocrlf = true
excludesfile = C:\Data\gitignore_global.txt