I am facing this issue during try to deploy script with gitlab ci/cd:
Initialized empty Git repository in C:/builds/Tri.BuiV/test-gitlab-cicd/.git/
fatal: detected dubious ownership in repository at 'C:/builds/Tri.BuiV/test-gitlab-cicd'
'C:/builds/Tri.BuiV/test-gitlab-cicd' is owned by:
'S-1-5-83-1-1989435290-1148643240-1709935003-3943614564'
but the current user is:
'S-1-5-93-2-1'
To add an exception for this directory, call:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
I tried:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
But the same error, why?
I tried:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
But get the same issue.
If the error persist, it probably means your git config --global (which impacts %USERPROFILE%\.gitconfig) does not use the same account as the one running your GitLab CICD.
If GitLab runs with a different account, it might try to access folder initially created by you.
The GitLab pipeline itself would need to include
git config --global --add safe.directory $CI_PROJECT_DIR
This i what is being automatically added for GitLab 15.8 in MR 3538.
Related
I've set up some credentials in Jenkins for bitbucket and double-checked the Credentials settings (e.g. logging in manually) however when I try it in Jenkins it just spins forever giving this output:
> git config remote.origin.url <bitbucket url> # timeout=10
Fetching upstream changes from <bitbucket url>
> git --version # timeout=10
using GIT_ASKPASS to set credentials <bitbucket account email> Bitbucket
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*
> git fetch --tags --progress <bitbucket url> +refs/heads/*:refs/remotes/origin/*
Note that the URL is fine when public. But when set to Private it simply fails with no output.
Is there anyway to debug this in a bit more detail?
I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.
I already had an option to input credentials in the git plugin so didn't need a separate credentials manager.
This is on MacOSX.
I changed the Jenkins setting on Git path to /usr/local/git as well as unset the credential.helper using git config, both don't work.
Finally, the problem was resolved by creating a default keychain file for jenkins in ~jenkins/Library/Keychains folder. Herewith is the steps...
sudo su jenkins
mkdir ~jenkins/Library/Keychains
cd ~jenkins/Library/Keychains
security create-keychain -p [pwd] ./Login.keychain
security login-keychain -d user -s ./Login.keychain
check default keychain setup properly
security default-keychain
git fetch --tags --progress https://github.com/....git +refs/heads/:refs/remotes/origin/
After that, the github userid/password is stored in jenkins default keychain and it will be used on jenkins build.
I had this problem on OSX. My issue was that Jenkins was using the wrong Git executable (I verified this by disabling the checkout step and adding which git before anything else).
I ran which git in terminal and copy-pasted the path into Manage Jenkins -> Global Tool Configuration -> Git -> Path to Git executable. It worked after that.
I had a similar issue, with Jenkins on a Windows server. I installed git with credentials manager and whenever it tried to checkout a private repository, it would wait for me to input credentials manually in the server. Disabling the git credential manager fixed it for me.
Actually, that should now (Q1 2021) work without having to disable the credential helper with Git 2.30.
"git credential(man)' didn't honor the core.askPass configuration variable (among other things), which has been corrected with Git 2.30 (Q1 2021).
See commit 567ad2c (15 Oct 2020) by Thomas Koutcher (koutcher).
(Merged by Junio C Hamano -- gitster -- in commit e0f6ad2, 02 Nov 2020)
credential: load default config
Signed-off-by: Thomas Koutcher
[jk: added test]
Signed-off-by: Jeff King peff#peff.net
Signed-off-by: Junio C Hamano gitster#pobox.com
Make git credential fill(man) honour the core.askPass variable.
As noted by kymikoloco in the comments, upgrading to the latest (Nov. 2021) Git for Windows 2.34 seems enough to solve the issue.
I had such problem with Jenkins on Windows 10. It always showed failure with permission denied error, code 128 returned by git.exe after ...GIT_ASKPASS for credentials step. Changing credential.helper and env.variable GIT_ASKPASS did not help me at all, the same behaviour.
Then i checked up which git.exe in cmd where git and was suprised, it was SmartGit's internal one.
I changed it to JGit in Jenkins global settings and it works now.
https://i.stack.imgur.com/IBfIi.png
Its works for me!
Goto Dashboard --> configuration
Scroll down to find Git plugin
input Global Config user.name Value: ex: jenkins
input Global Config user.email Value ex: youremail#gmail.com
you need to generate an SSH key from Git and add it to Bitbucket
I have installed jenkins on my centos7 server and tried to build a maven build. Created a new maven build job and in SCM I was trying to pull the code from github but it showed me an error like...
Failed to connect to repository : Command "git ls-remote -h https://github.com/example.git HEAD" returned status code 128: stdout: stderr: remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/example.git/'
And also I setup an SSH public keys to my github. I don't know how to solve this. Anyone help me.Thanks in advance.
also I setup an SSH public keys to my github
That would have zero impact on an HTTPS URL: the SSH key is ignored.
Check if you havbe a git credential helper in place which might cache your credentials (GitHub username/password)
git config credential.helper
For instance, it could be 'cache'.
I would recommend (as in this answer) to set it to gnome-keyring:
git config --global credential.helper gnome-keyring
Then try again your git ls-remote, from command-line:
git ls-remote https://<yourUsername>#github.com/<yourUsername>/<yourRepo.git>
That should prompt for your GitHub username/password. Once entered, a second git ls-remote should not ask again for your credentials.
From there, an SCM process from your Jenkins, as long as said Jenkins runs with your account, should work.
I was working in branch master, and committing to Git repository. Everything worked fine. I connected new app to this repository on Heroku.
I was committing to both Heroku and Git. Everything worked fine again (except I cannot run db:migrate on Heroku but that is another question...). After my last commit I run git status and received: On branch master. Your branch is up-to-date with 'origin/master'.
Today I made some changes in my code, but suddenly I cannot commit - received error "Please tell me who you are." The only difference from previous commits is that had a migration, if it is of any importance.
When I run git config --global --get user.emailcommand I get an empty line in return.
Why have I suddenly lost connection to git?
It seems that your email, and name parameters in global config are empty. Probably you have executed something like this, that has dropped the values:
git config --global user.name ""
git config --global user.email ""
Just fill them with commands again:
git config --global user.name "Your Name"
git config --global user.email "your#email.com"
Where your#email.com is your github email.
NOTE: You can push out of hand to heroku, bypassing the github, since heroku also have git repo itself.
I'm trying to checkout, and build my git project in a custom folder using Jenkins. I have set the custom workspace from the "Advance Project Options" tab. However, whenever I try to run the project, I get the following error:
Building in workspace /myapp
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/.../... # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
ERROR: Error fetching remote repo 'origin'
ERROR: Error fetching remote repo 'origin'
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE
But if I run the project in the default workspace, it seems to work fine.
I'm wondering whether the structure of my custom workspace is wrong. Basically, I have the following setup:
The name of my git repo is "myapp". When I use the defualt workspace, the project is checked out, and built in: /var/lib/jenkins/jobs/myjob/workspace/[files inside myapp repo]. After this, I have to copy the files from the default workspace to my actual folder using:
cp /var/lib/jenkins/jobs/myjob/workspace/* /myapp/.
But for the custom workspace, I have given the directory as /myapp. I want Jenkins to checkout the code from git into /myapp, and then do the build. Would the folder structure cause any problems? If not, why is it failing?
Has anybody has same problem?
I connected Gitlab ci with Gitlab. When test run Gitlab CI can't clone Gitlabs repo.
Got this error:
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds && git clone http://gitlab-ci-token:
<mytoken>#gitlab.xlab.si/primoz_godec/scrum_app.git project-3 && cd project-3 && git checkout
<othertoken>
Cloning into 'project-3'...
fatal: protocol error: bad line length 8188
Problem was that http clone has been disabled on Gitlab. After enabling it everything was ok.