У нас есть корпоративный github, работающий на удаленном github-сервере за пределами сети нашей компании, и нам нужно использовать https-прокси для клонирования. Нам не разрешено использовать аутентификацию по паролю, поэтому либо ssh (который не разрешен из-за проблем с прокси), либо PAT.
В моей командной строке команда
git clone https://user:token@github.exampleco.com/org/repo.git
клонирует репозиторий без проблем, и это занимает около 5-10 секунд.
В Jenkins вывод консоли гласит «клонирование в имя каталога», а затем вращающееся колесо, которое вращается бесконечно, и это никогда не разрешается.
Я выполняю это в скрипте execute shell, так как плагин github запускает некоторые команды, которые, очевидно, все еще хотят выполнять аутентификацию по паролю, даже когда я передаю ему PAT-версию URL без учетных данных, и я не вижу Опция авторизации PAT в модале добавления учетных данных.
Чтобы уточнить URL-адрес, данный плагину Jenkins:
https://user:token@github.exampleco.com/org/repo.git
и я получаю такой вывод:
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://user:token@github.exampleco.com/org/repo.git # timeout=10
Fetching upstream changes from https://user@github.exampleco.com/org/repo.git
> git --version # timeout=10
Setting http proxy: corporateproxy.com:8080
> git fetch --tags --progress https://user@github.exampleco.com/org/repo.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://user@github.exampleco.com/org/repo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1818)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://user@github.exampleco.com/org/repo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.exampleco.com/settings/tokens or https://github.exampleco.com/settings/ssh
fatal: unable to access 'https://user@github.exampleco.com/org/repo.git': The requested URL returned error: 403
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
Я замечаю, что user: token @ отбрасывается в пользу просто user @ после настройки удаленного источника. Я попытался запустить все эти команды вручную в оболочке, и когда я дошел до второй, то есть:
git fetch --tags --progress https://user:token@github.exampleco.com/org/repo.git
он также просто бездействовал вечно, как команда клона.