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

Fail to fetch from Gitea using API key

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: gitea-plugin
    • Environment:
      Jenkins: 2.287
      Gitea plugin: 1.2.1
      Gitea server: try.gitea.io (version 1.15.0+dev-114-g63411309f)
      Git version: 2.7.4 / 2.29.2
      OS: Windows 10 / Ubuntu 16.04
      JDK: 8 (OpenJDK) / 11 (AdoptOpenJDK)
    • Similar Issues:

      Description

      After server restart, git checkout from gitea using an API key fails. If the used project type is a 'multibranch pipeline' or derived from that, it is possible to manually scan the repo, after which it will work until the next server restart.

      Steps to reproduce:

      1) Setup an account at try.gitea.io. Create a repo for testing and add a Jenkinsfile (https://www.jenkins.io/doc/book/pipeline/jenkinsfile/). Make sure the repo is set to private.

      2) Get an API key for your account (Settings > Applications, input a token name and click generate. Make sure to copy the token, as it will not be displayed again.)

      3) Setup your Jenkins with the Gitea plugin.

      4) Add https://try.gitea.io/ as 'Gitea server' under 'Configure'. 

      5) Select 'New element', enter a name for it and create a new multibranch pipeline

      6) Under 'branch sources', select gitea. Select try.gitea.io as server (if its not pre-selected).

      7) Add your previously generated token as credentials (Gitea personal access token). In the owner field add your username on try.gitea.org and your repository name.

      8) Click 'Save'. Jenkins should now scan you repo.

      9) Click 'status' and select the master branch. Select 'Build now'. If your repo contains a Jenkinsfile, Jenkins should build that.

      10) After the build is completed, restart Jenkins.

      11) Once the server is up again, start a new build. It should fail with 

      hudson.plugins.git.GitException: Failed to fetch from https://try.gitea.io/nils91/jenkins_test.git
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1000)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1301)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --no-tags --force --progress -- https://try.gitea.io/nils91/jenkins_test.git +refs/heads/master:refs/remotes/origin/master" returned status code 128:
      stdout: 
      stderr: fatal: Cannot prompt because user interactivity has been disabled.
      remote: invalid credentials from 172.19.0.2:57920
      fatal: Authentication failed for 'https://try.gitea.io/nils91/jenkins_test.git/'
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2639)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2079)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:601)
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:998)
      	... 11 more
      

      12) Select 'Up' and click 'Scan multipranch pipeline now'

      13) Navigate back to master and start a new build. It should succeed again.

       

      The issue started appearing some weeks ago after an upgrade. Not sure which version though, probably 2.284 or 2.285. I don´t know which version i had before, so might have started a bit earlier.

        Attachments

          Activity

          Hide
          nils91 Nils Dralle added a comment - - edited

          JENKINS-60331 sounds similar and might be related, however that one is using SSH, while i´m using a token.

          Show
          nils91 Nils Dralle added a comment - - edited JENKINS-60331 sounds similar and might be related, however that one is using SSH, while i´m using a token.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            nils91 Nils Dralle
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: