I'm trying to set up Jenkins to work with git webhooks. So far I have
jenkins
user*/develop
to only watch the dev branch/data/www/<site>
ubunutu
group to the jenkins
user (see below)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.
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:
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):
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
This works pretty nice form me:
1 - Find the git config.lock
file, inside the jenkins folder run:
find . -type f -name "config.lock"
2 - Delete the config.lock
file founded.
Thats it!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With