Trouble Using Library

Hi,

I want to use a library, as suggested here: https://www.youtube.com/watch?v=Wj-weFEsTb0

I have a jenkins server and a gitea server with a number of orgs and repos, and I also have token with which Jenkins can access the gitea server. On the Jenkins side, I have a Gitea organisation to access such an org and the repos in there. I push to the gitea server, and it triggers a job on Jenkins, which then checks out the repo and does its thing. This part works. Now I wanted to create a library that Jenkins should load some Groovy code from, so I configured a library under “Manage Jenkins” → “System”, using the same token and an URL to the specific repo that contains the library. When I save the configuration, Jenkins displays:

“Currently maps to revision: a5b905…”

beneath the library, indicating that Jenkins can access the library. Now, I want to use the library in a pipeline script, so I created a test pipeline like this:

Library('test-library') _

However, when I run this pipeline, I get

> git ls-remote -h -- https://my.example.com/org/library.git # timeout=10
ERROR: Checkout failed
hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my.example.com/org/my-library.git" returned status code 128:
stdout: 
stderr: remote: Verify
fatal: Authentication failed for 'https://my.example.com/org/my-library.git/'

Jenkins is using the same credential, ie. token, for all gitea access.

Oh. Suddenly, I also see this in my proxy’s log:

1.2.3.4 - Username for 'https [02/Mar/2025:14:35:29 +0100] GET /org/library.git/info/refs?service=git-upload-pack HTTP/2.0 "401" 7 "-" "git/2.39.5"

Please note the “Username for 'https” part of the log, which should be empty, but obviously isn’t. I also have no idea where it comes from.

I’m very confused as to why Jenkins can check the repo to see what the latest commit is, but not check it out?

Jenkins’ permissions on the org are:

Code                        Read
Issues                      Read
Pull Requests               Read
Releases                    Read
Wiki                        Read
Access to External Wiki     No Access
Access to External Issues   No Access
Projects                    Read
Packages                    Read
Actions                     Read

On the repo, I tried having no special config, having Jenkins with “Read” access, and having Jenkins with “Write” access. I also tried giving Jenkins ‘Write’ access to code at the org level, all for naught.

Does anyone have a good idea on how to debug this, please?

Jenkins setup: Please see Pain with Python and Coverage

I have created separate credentials which work, but this is highly unsatisfactory. All credentials are in the global system store.

Also, the token now appears in the proxy’s log files. Yikes!

For the token credential I’m using in the gitea org, access logs in the proxy look like anonymous access (ie, ‘- -’), which is what I want.