I am trying to run a script with GitPython, but it seems to only fail when I run from inside the Jenkins automation environment. The error that it gives isn't very helpful (and I haven't been able to find a solution for it in my searching), so I'm hoping someone here can help.
Here's some data for my setup.
- Git version: 2.45.2
- python version: 3.12.4 (in a virtual environment)
- GitPython module: 3.1.43
Error encountered (proprietary pathnames and other secrets removed):
Traceback (most recent call last):
File "/path/to/auth_tester.py", line 5, in <module>
repository.remote().pull()
File "/path/to/pyenv/lib/python3.12/site-packages/git/remote.py", line 1123, in pull
res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/pyenv/lib/python3.12/site-packages/git/remote.py", line 895, in _get_fetch_info_from_stderr
proc.wait(stderr=stderr_text)
File "/path/to/pyenv/lib/python3.12/site-packages/git/cmd.py", line 834, in wait
raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git pull -v -- origin
Sample of the code that causes it (secrets also removed):
import os
from git import Repo
repository = Repo(".")
repository.remote().pull()
Is there an environment variable that might be missing from the Jenkins run, that would be included when I run it locally?
git pull -v -- origin
work if you run it manually? Do you need authorization to pull from the remote repository? Remember, Jenkins is (probably) running as a different user than you.