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
Related
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.
I am trying to link a gitlab instance with a Jenkins instance. Due to being run in a DC/OS environment I cannot use the standard SSH port 22, so I am running gitlab on SSH port 16122 instead.
Gitlab displays SSH clone URLs in the format [git#git.company.de:16122]:user/test.git, which a normal git clone command understands. Also, Jenkins accepts this URI as SCM URI in the configuration screen (as evidenced by the error messages "invalid credentials" vanishing once I set the SSH key as credential that is configured as deploy-key in Gitlab.
The problem arises during actually building the job: jenkins for some unknown reason decides to double-urlencode the [ at the front of the URI and thus the build breaks:
Cloning repository %255bgit#git.company.de:16122]:user/test.git
> git init /var/jenkins_home/workspace/test # timeout=10
Fetching upstream changes from %25255bgit#git.company.de:16122]:user/test.git
> git --version # timeout=10
> git fetch --tags --progress %25255bgit#git.company.de:16122]:user/test.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress %25255bgit#git.company.de:16122]:user/test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
When I look at the raw XML of the job using xxd on the shell, there are no "invisible" ASCII chars or similar in front of the repo URL.
What causes this, and is there a way to fix this without having to manually rewrite every URL to ssh://git#git.company.de:16122/user/test.git?
I am new to Jenkins CI. However the issue looks very easy enough but its not working for me. My source code is in GIT and i am using Git repository for that.
I am getting the error below.
Thanks in Advance.
Started by user abc
Building on master in workspace /var/lib/jenkins/workspace/Hello World
git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url
Fetching upstream changes from
git --version # timeout=10
using .gitcredentials to set credentials
git config --local credential.helper store --file=/tmp/git7943155421179786207.credentials # timeout=10
git fetch --tags --progress +refs/heads/:refs/remotes/origin/
git config --local --remove-section credential # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 833228fa50173e7977b4d5ee86c1385b5c6494be (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 833228fa50173e7977b4d5ee86c1385b5c6494be
git rev-list 833228fa50173e7977b4d5ee86c1385b5c6494be # timeout=10
Path To MSBuild.exe: msbuild.exe
Executing the command msbuild.exe NimbusAutomation.sln from /var/lib/jenkins/workspace/Hello World
[Hello World] $ msbuild.exe ABCAutomation.sln
Build step 'Build a Visual Studio project or solution using MSBuild' changed build result to FAILURE
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Warning: this build has no associated authentication, so build permissions may be lacking, and downstream projects which cannot even be seen by an anonymous user will be silently skipped
Finished: FAILURE
This can be caused by not configuring a jobs authorization policy correctly.
Check either the downstream job to see its configuration, or go to
Manage Jenkins-> Configure Global Security -> Access Control for Builds -> Configure Build Authorizations in Project Configuration
And check the global settings.
After finding the parent settings, go to the project giving the error select the same configuration in the section that looks like :
If this still does not work, you might also need to make sure that the user has the adequate permissions if you are using matrix based security.
Manage Jenkins-> Configure Global Security -> Authorization
And in the authorization matrix make sure the necessary user has build permissions
See also
Authorize project plugin
How To Configure Access Control For Builds
Thanks. I did all the advised settings above, it only resulted in Warning message to disappear, the build still fails.
The build works fine on my local Command prompt when i pass - msbuild.exe NimbusAutomation.sln but still fails on jenkins...
Path To MSBuild.exe: msbuild.exe
Executing the command msbuild.exe msbuild.exe NimbusAutomation.sln NimbusAutomation.sln from /var/lib/jenkins/workspace/Hello World
[Hello World] $ msbuild.exe msbuild.exe NimbusAutomation.sln NimbusAutomation.sln
Build step 'Build a Visual Studio project or solution using MSBuild' changed build result to FAILURE
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE
Solutions
When configing the branchs to build remove the wildcard *:
*/master to be only master
This error only occours when a GIT SCM is related to the JOB.
Ex: I have a daily job to build an Android project.
First i thought that it was a cron problem, currently im using 50 10 * * *, but i have tried H 10 * * * without any success. When the time comes, it always build the job (Failure or Success) and it queue another job.. and so on...
Would last have run at Friday, May 22, 2015 10:01:58 AM BRT; would next run at Saturday, May 23, 2015 10:01:58 AM BRT.
Even a build with parameter it queue a another job everytime.
So it stays in a build loop, forever..
Config:
Jenkins ver. 1.614.
Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-46-generic x86_64)
GIT client plugin: 1.17.1
GIT plugin: 2.3.5
Console Output:
Started by an SCM change
Building in workspace .../jobs/PROJECT_NAME/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url ssh://GIT_ADDRESS/ # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
Fetching upstream changes from ssh://GIT_ADDRESS/
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress ssh://GIT_ADDRESS/ +refs/heads/master:refs/remotes/origin/master
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Multiple candidate revisions
Scheduling another build to catch up with PROJECT_NAME
Checking out Revision e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6
> git rev-list e6d726c2d31cb0d7e6fad4362ee85e6fac1712c6 # timeout=10
[Gradle] - Launching build.
[android] $ gradle clean build assemble
...
Maybe the problem is this?
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Multiple candidate revisions
Scheduling another build to catch up with PROJECT_NAME
The build loop:
Job Config:
Global Config:
Review the beginning of the console logs, for both the job that you manually started, and the job that gets queued next automatically.
In the beginning of the console log, it gives a reason for why the build was triggered, for example 09:46:05 Started by an SCM change or 16:06:58 Started by user Slav. Please add to the question the start of both console logs.
Edit:
Now that we know that Jenkins detects an SCM change trigger we can further speculate that what's causing this behaviour is an SCM post-commit hook of some sort, or another script activation sending a request to Jenkins.
Post-commit hooks should not work if SCM polling is not enabled, but nothing else makes sense, so let's investigate that avenue. Add /pollingLog/ to the build URL of the build number that was triggered "by SCM change". There is a chance that nothing would be found, but if there is, but let's make sure.
Next, if possible, bind Jenkins to a different IP address and/or port. If there are "rogue" scripts that are triggering secondary builds, they won't be able to adapt to changed address.
Edit 2:
Looks like there is a bug in git client plugin itself, it was fixed in version 1.6.2. Please check the version of your git plugins.
Sources: https://issues.jenkins-ci.org/browse/JENKINS-10767 and https://issues.jenkins-ci.org/browse/JENKINS-20286
Above screen shot looks fine but i am sure there must be some other configuration.
can you provide detail (rest of the) configuration too?
Please give below code in Build periodically section and try if that resolves the issue
H(0-50) 10 * * *
Make sure your repo doesn't have more than one branch that matches your Branch Specifier by using the full path to the branch: "refs/heads/master" instead of "*/master"
I've installed Jenkins on my local build server and I'm trying to get it to poll bitbucket for changes to my repo and I can't get it to work as I'd like. I'd like to Build when a change is pushed to BitBucket, but I can't get that to work. (I checked "Build when a change is pushed to BitBucket". In the mean time I've set it up to poll bitbucket with the settings "H/2 * * * *" which I understand to mean that it should poll every 2 minutes. This appears to be working, but I don't know how to get it to poll only when changes are pushed to bitbucket.
Started on Feb 10, 2015 8:45:47 AM
Using strategy: Default
[poll] Last Built Revision: Revision 354dd174247f76e3e78327707a89b0ef370b68ed (refs/remotes/origin/master)
using .gitcredentials to set credentials
git.exe --version # timeout=10
git.exe init C:\Windows\TEMP\hudson8917091258929317136tmp # timeout=10
git.exe config --local credential.helper store --file=\"C:\Windows\TEMP\git1000935734599110528.credentials\" # timeout=10
git.exe -c core.askpass=true ls-remote -h https://BGoldberg#bitbucket.org/CPA2Biz/souptest.git master # timeout=10
git.exe config --local --remove-section credential # timeout=10
[poll] Latest remote head revision is: 354dd174247f76e3e78327707a89b0ef370b68ed
Done. Took 4.6 sec
No changes
I think you need to configure BitBucket to inform Jenkins when some new code is pushed to BitBucket.
The following link explains how to do this in BitBucket
https://confluence.atlassian.com/display/BITBUCKET/Jenkins+hook+management