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

Bitbucket authentication with token in pipelines



    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: pipeline
    • Labels:
    • Environment:
      Jenkins 2.303.1
      Plugins Up-to-date
    • Similar Issues:


      If my credentials as based on username and token I get the following error on pipeline jobs for the first checkout

      00:00:41.960  [Pipeline] {
      00:00:41.996  [Pipeline] stage
      00:00:42.009  [Pipeline] { (Declarative: Checkout SCM)
      00:00:42.063  [Pipeline] checkout
      00:00:42.077  The recommended git tool is: C:\Program Files\Git\cmd\git.exe
      00:00:42.109  using credential 7904aa37-f4d5-430c-941a-c18eb5d13e6b
      00:00:42.189  Fetching changes from the remote Git repository
      00:00:42.251  Fetching without tags
      00:00:42.421  ERROR: Error fetching remote repo 'origin'
      00:00:42.421  hudson.plugins.git.GitException: Failed to fetch from ssh://git@bitbucket.our-website.de/tools/io.git
      00:00:42.421  	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1004)
      00:00:42.421  	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245)
      00:00:42.421  	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
      00:00:42.421  	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      00:00:42.421  	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
      00:00:42.421  	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
      00:00:42.421  	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      00:00:42.421  	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      00:00:42.421  	at java.util.concurrent.FutureTask.run(Unknown Source)
      00:00:42.421  	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      00:00:42.421  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      00:00:42.421  	at java.lang.Thread.run(Unknown Source)
      00:00:42.421  Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\cmd\git.exe fetch --no-tags --force --progress -- ssh://git@bitbucket.our-website.de/tools/io.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      00:00:42.421  stdout: 
      00:00:42.421  stderr: git@bitbucket.amazone.de: Permission denied (publickey).
      00:00:42.421  fatal: Could not read from remote repository.
      00:00:42.421  Please make sure you have the correct access rights
      00:00:42.421  and the repository exists.

      While with the same credentials my freestyle jobs run just fine:

      00:00:00.451 The recommended git tool is: NONE
      00:00:00.463 using credential 7904aa37-f4d5-430c-941a-c18eb5d13e6b
      00:00:00.474 Cloning the remote Git repository
      00:00:00.478 Cloning repository ssh://git@bitbucket.our-website.de/basis/daisychain.git
      00:00:00.479  > C:\Program Files\Git\cmd\git.exe init d:\jenkins_agent\workspace\DEV_BASIS\DEV_DAISYCHAIN # timeout=10
      00:00:00.536 Fetching upstream changes from ssh://git@bitbucket.our-website.de/basis/daisychain.git
      00:00:00.537  > C:\Program Files\Git\cmd\git.exe --version # timeout=10
      00:00:00.553  > git --version # 'git version 2.32.0.windows.1'
      00:00:00.553 using GIT_ASKPASS to set credentials bitbucket token access

      On my multibranch jobs the branch discovery works also with the same credential.
      If I switch to private key authentication the same job works but I would prefer to use the token.
      I'm not 100% shure if this is a bug or a feature request but I didn't found any information that it shouldn't work.



          There are no comments yet on this issue.


            Unassigned Unassigned
            timsch Tim Schl├╝ter
            0 Vote for this issue
            2 Start watching this issue