Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-24368

Authentication failed for https://username@bitbucket.org/project/repository.git

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-client-plugin
    • None
    • git client plugin 3.6.0

      Getting the following error after updating
      GIT plugin: 1.5.0 > 2.2.5
      GIT client plugin: 1.3.0 > 1.10.1

      ERROR: Error cloning remote repo 'origin'
      hudson.plugins.git.GitException: Command "C:/Progra~2/Git/bin/git.exe fetch --tags --progress https://username@bitbucket.org/project/repository.git +refs/heads/:refs/remotes/origin/" returned status code 128:
      stdout:
      stderr: fatal: Authentication failed for 'https://username@bitbucket.org/project/repository.git/'

      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1407)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1195)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:266)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:422)
      at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:857)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:890)
      at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:118)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1255)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
      at hudson.model.Run.execute(Run.java:1740)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:233)

          [JENKINS-24368] Authentication failed for https://username@bitbucket.org/project/repository.git

          Mark Waite added a comment - - edited

          The git-client-plugin 1.14.0 change to remove the call to JGit implementation of checkCredentials resolved this issue for me. I can clone from https://markewaite@bitbucket.org/markewaite/bin.git, a private bitbucket repository using stored credentials as reported in JENKINS-22694.

          With git plugin 2.3.5 and git client plugin 1.16.1, I cannot access a private bitbucket repository when the user name and password are embedded in the https URL. Refer to JENKINS-26757 for what appears to be a duplicate report.

          Mark Waite added a comment - - edited The git-client-plugin 1.14.0 change to remove the call to JGit implementation of checkCredentials resolved this issue for me. I can clone from https://markewaite@bitbucket.org/markewaite/bin.git , a private bitbucket repository using stored credentials as reported in JENKINS-22694 . With git plugin 2.3.5 and git client plugin 1.16.1, I cannot access a private bitbucket repository when the user name and password are embedded in the https URL. Refer to JENKINS-26757 for what appears to be a duplicate report.

          Mark Waite added a comment - - edited

          Credential based access to bitbucket repository works correctly.

          Embedded user name and password in the https URL does not work with private repositories on bitbucket or GitHub (even using an access token that works from the command line) or GitLab.

          Embedded user name and password in the https URL works with public repos on bitbucket and GitHub and GitLab.

          Jenkins credential based https access to private and public repositories works as expected on bitbucket, GitHub, and GitLab.

          Mark Waite added a comment - - edited Credential based access to bitbucket repository works correctly. Embedded user name and password in the https URL does not work with private repositories on bitbucket or GitHub (even using an access token that works from the command line) or GitLab. Embedded user name and password in the https URL works with public repos on bitbucket and GitHub and GitLab. Jenkins credential based https access to private and public repositories works as expected on bitbucket, GitHub, and GitLab.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java
          http://jenkins-ci.org/commit/git-client-plugin/ff9c219277531dcf0f18dccd6d8665118e1827a3
          Log:
          Add username/password support to CredentialsTest

          Help test JENKINS-26757, JENKINS-24368 and JENKINS-28460.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java http://jenkins-ci.org/commit/git-client-plugin/ff9c219277531dcf0f18dccd6d8665118e1827a3 Log: Add username/password support to CredentialsTest Help test JENKINS-26757 , JENKINS-24368 and JENKINS-28460 .

          Mark Waite added a comment - - edited

          The change from Jacob Keller that is current available in a git-client-plugin pre-release of 1.18.1 seems to resolve this for https URL's.

          I was able to embed my username and password into an https URL to a private bitbucket repository and it cloned successfully without using the credentials system.

          Mark Waite added a comment - - edited The change from Jacob Keller that is current available in a git-client-plugin pre-release of 1.18.1 seems to resolve this for https URL's. I was able to embed my username and password into an https URL to a private bitbucket repository and it cloned successfully without using the credentials system.

          Flavio Donzé added a comment -

          Just updated to:
          GIT client plugin: 1.18.1-SNAPSHOT (private-ff9c2192-jenkins)
          GIT plugin: 2.4.0

          Still getting the exception, slightly different stacktrace though:

          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Command "C:/Progra~2/Git/bin/git.exe -c core.askpass=true fetch --tags --progress https://username@bitbucket.org/project/repository.git +refs/heads/:refs/remotes/origin/" returned status code 128:
          stdout:
          stderr: fatal: Authentication failed for 'https://scodi@bitbucket.org/scodi/tools.git/'

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1605)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1368)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:62)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:300)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:486)
          at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1003)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1043)
          at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:129)
          at hudson.scm.SCM.checkout(SCM.java:485)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1284)
          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:1741)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:381)

          Flavio Donzé added a comment - Just updated to: GIT client plugin: 1.18.1-SNAPSHOT (private-ff9c2192-jenkins) GIT plugin: 2.4.0 Still getting the exception, slightly different stacktrace though: ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "C:/Progra~2/Git/bin/git.exe -c core.askpass=true fetch --tags --progress https://username@bitbucket.org/project/repository.git +refs/heads/ :refs/remotes/origin/ " returned status code 128: stdout: stderr: fatal: Authentication failed for 'https://scodi@bitbucket.org/scodi/tools.git/' at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1605) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1368) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:62) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:300) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:486) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1003) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1043) at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:129) at hudson.scm.SCM.checkout(SCM.java:485) at hudson.model.AbstractProject.checkout(AbstractProject.java:1284) 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:1741) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:381)

          Mark Waite added a comment -

          Thanks for checking. I had run that test interactively and thought it worked. An automated test is definitely working in my test harness. Unfortunately, when I just attempted the same thing from a fresh docker instance of Jenkins using https://username:password@bitbucket.org/username/private-repo.git, it failed. I then used the same repository URL from command line git and confirmed it works correctly.

          The automated test must not be matching the real world closely enough. I'll explore further as time allows.

          Mark Waite added a comment - Thanks for checking. I had run that test interactively and thought it worked. An automated test is definitely working in my test harness. Unfortunately, when I just attempted the same thing from a fresh docker instance of Jenkins using https://username:password@bitbucket.org/username/private-repo.git , it failed. I then used the same repository URL from command line git and confirmed it works correctly. The automated test must not be matching the real world closely enough. I'll explore further as time allows.

          Jim Klo added a comment -

          I am having this same issue after modifying my password within the credentials file. I'm not able to perform any git authenticated action with that user/password combination.

          I discovered on my OS X Jenkins server that:

          • the temporary git<timestamp>.credentials file that extracted to the user's private temp (/var/folders/...) contained both old/new credentials!
          • after removing all stored user credentials, and then creating a new credential user, if I used Safari 9 as the browser - Junk would be stored in the password field, if I use Chrome the password is saved correctly.
          • Once I had the correct password showing up in the git*.credentials file; It still would not authenticate, however I noticed that the password was NOT correctly URL Encoded; chars ' {' and '}

            ' that are part of the password were not encoded. If I use unencoded versions of those characters in Repository URL [ https://user:passwordcontaining{}@server/foo/bar.git ] I get the authentication failure, however if I URL encode [ https://user:passwordcontaining%7B%7D@server/foo/bar.git ] everything works.

          Jim Klo added a comment - I am having this same issue after modifying my password within the credentials file. I'm not able to perform any git authenticated action with that user/password combination. I discovered on my OS X Jenkins server that: the temporary git<timestamp>.credentials file that extracted to the user's private temp (/var/folders/...) contained both old/new credentials! after removing all stored user credentials, and then creating a new credential user, if I used Safari 9 as the browser - Junk would be stored in the password field, if I use Chrome the password is saved correctly. Once I had the correct password showing up in the git*.credentials file; It still would not authenticate, however I noticed that the password was NOT correctly URL Encoded; chars ' {' and '} ' that are part of the password were not encoded. If I use unencoded versions of those characters in Repository URL [ https://user:passwordcontaining {}@server/foo/bar.git ] I get the authentication failure, however if I URL encode [ https://user:passwordcontaining%7B%7D@server/foo/bar.git ] everything works.

          Mark Waite added a comment -

          Works with JGit 5.10.0 as included in git client plugin 3.6.0

          Mark Waite added a comment - Works with JGit 5.10.0 as included in git client plugin 3.6.0

          Sabo Shao added a comment -

          Git client plugin  3.12.1

          Jenkins 2.374

           

          This problem still exists. I have save  my username and password in Jenkins credentials.

          It will happen occasionally. But when I run the job again, it will work normally again. This is very confusing.

           
          ERROR: Error cloning remote repo 'origin'13:48:32 hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress – http://ip:port/scm/project/repo.git +refs/pull-requests/562/from:refs/remotes/origin/PR-562" returned status code 128:13:48:32 stdout: 13:48:32 stderr: fatal: Authentication failed for ' 'http://ip:port/scm/project/repo.git[/|http://192.168.13.28:7990/scm/luban/service.git/]'13:48:32 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2697)13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111)13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:87)13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:852)13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:158)13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:151)13:48:32 at hudson.remoting.UserRequest.perform(UserRequest.java:211)13:48:32 at hudson.remoting.UserRequest.perform(UserRequest.java:54)13:48:32 at hudson.remoting.Request$2.run(Request.java:376)13:48:32 at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)13:48:32 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)13:48:32 at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:121)13:48:32 at java.base/java.lang.Thread.run(Thread.java:829)13:48:32 Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to 97_PR*13:48:32* at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)13:48:32 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)13:48:32 at hudson.remoting.Channel.call(Channel.java:1000)13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:143)13:48:32 at jdk.internal.reflect.GeneratedMethodAccessor804.invoke(Unknown Source)13:48:32 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)13:48:32 at java.base/java.lang.reflect.Method.invoke(Method.java:566)13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:129)13:48:32 at com.sun.proxy.$Proxy199.execute(Unknown Source)13:48:32 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1229)13:48:32 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1312)13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)13:48:32 at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)13:48:32 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)13:48:32 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)13:48:32 at java.base/java.lang.Thread.run(Thread.java:834)
           

           

          Sabo Shao added a comment - Git client plugin  3.12.1 Jenkins 2.374   This problem still exists. I have save  my username and password in Jenkins credentials. It will happen occasionally. But when I run the job again, it will work normally again. This is very confusing.   ERROR: Error cloning remote repo 'origin' 13:48:32 hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress – http://ip:port/scm/project/repo.git +refs/pull-requests/562/from:refs/remotes/origin/PR-562" returned status code 128: 13:48:32 stdout: 13:48:32 stderr: fatal: Authentication failed for ' 'http://ip:port/scm/project/repo.git[/|http://192.168.13.28:7990/scm/luban/service.git/]' 13:48:32 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2697) 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111) 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:87) 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623) 13:48:32 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:852) 13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:158) 13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:151) 13:48:32 at hudson.remoting.UserRequest.perform(UserRequest.java:211) 13:48:32 at hudson.remoting.UserRequest.perform(UserRequest.java:54) 13:48:32 at hudson.remoting.Request$2.run(Request.java:376) 13:48:32 at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) 13:48:32 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 13:48:32 at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:121) 13:48:32 at java.base/java.lang.Thread.run(Thread.java:829) 13:48:32 Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to 97_PR*13:48:32* at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784) 13:48:32 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) 13:48:32 at hudson.remoting.Channel.call(Channel.java:1000) 13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:143) 13:48:32 at jdk.internal.reflect.GeneratedMethodAccessor804.invoke(Unknown Source) 13:48:32 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 13:48:32 at java.base/java.lang.reflect.Method.invoke(Method.java:566) 13:48:32 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:129) 13:48:32 at com.sun.proxy.$Proxy199.execute(Unknown Source) 13:48:32 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1229) 13:48:32 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1312) 13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129) 13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97) 13:48:32 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84) 13:48:32 at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) 13:48:32 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) 13:48:32 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 13:48:32 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 13:48:32 at java.base/java.lang.Thread.run(Thread.java:834)    

          Mark Waite added a comment -

          sabo_shao this was not an intermittent issue. It failed consistently. You are saying that it fails intermittently for you.

          This issue required that the URL syntax must include https://username@bitbucket.example.com/ format. The URL that you are using is not that format.

          Based on those two items, I doubt that this issue is the same as the issue you are seeing.

          Intermittent failures usually will have a log message written on the Bitbucket server that indicates why the authentication failed. Check with the Bitbucket administrator to see if they can identify the root cause of the intermittent authentication failure.

          Mark Waite added a comment - sabo_shao this was not an intermittent issue. It failed consistently. You are saying that it fails intermittently for you. This issue required that the URL syntax must include https://username@bitbucket.example.com/ format. The URL that you are using is not that format. Based on those two items, I doubt that this issue is the same as the issue you are seeing. Intermittent failures usually will have a log message written on the Bitbucket server that indicates why the authentication failed. Check with the Bitbucket administrator to see if they can identify the root cause of the intermittent authentication failure.

            Unassigned Unassigned
            flaviodonze Flavio Donzé
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: