Проблема с конфигурацией Jenkins и Git

Я использую Git уже некоторое время.

Недавно я начал изучать Jenkins, и мне удалось настроить его с помощью родного установщика Windows. Я создал пример проекта в своей локальной системе и успешно построил его с помощью Jenkins.

Теперь у меня есть проект на удаленном сервере, и я хочу, чтобы Дженкинс вытащил этот код с помощью Git.

Я сделал следующее:

1) Установил подключаемый модуль Git. введите здесь описание изображения

2) В Jenkins > Управление Jenkins > Настройка системы > Git > Установка Git -

введите здесь описание изображения

[также пробовал C:\Program Files (x86)\Git\cmd\gitk.cmd вместо ....\git.exe]

3) В тестовом проекте > Настройте введите здесь описание изображения

4) Наконец-то попробовал собрать. Но всегда получайте ошибку тайм-аута, а затем сбой. введите здесь описание изображения

Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\GitTest
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\cmd\git.exe config remote.origin.url ssh://git@<the-url-to-the-server>demo_android.git # timeout=10
Fetching upstream changes from ssh://git@<the-url-to-the-server>demo_android.git
 > C:\Program Files (x86)\Git\cmd\git.exe --version # timeout=10
 > C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress ssh://git@<the-url-to-the-server>demo_android.git +refs/heads/*:refs/remotes/origin/* # timeout=60
FATAL: Failed to fetch from ssh://git@<the-url-to-the-server>demo_android.git
hudson.plugins.git.GitException: Failed to fetch from ssh://git@<the-url-to-the-server>demo_android.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:647)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:889)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:914)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1258)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
    at hudson.model.Run.execute(Run.java:1759)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress ssh://git@<the-url-to-the-server>demo_android.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host git.us1.adeptra.com port 7999: Bad file number
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1435)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1223)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:85)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:280)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:645)
    ... 10 more

Что я делаю не так? Нужно ли мне предоставлять учетные данные? (я пробовал, тоже не получилось)


person senchaDev    schedule 30.10.2014    source источник
comment
Вы можете сделать git fetch --tags --progress ssh://git@<the-url-to-the-server>demo_android.git на своем локальном компьютере?   -  person mithrop    schedule 30.10.2014
comment
Да. Я перешел в конкретный каталог и выполнил команду. Как обычно, он запросил парольную фразу, а затем попытался получить   -  person senchaDev    schedule 30.10.2014


Ответы (3)


Решил! У ключа SSH была парольная фраза. Я удалил его, и он работал нормально.

Удалил парольную фразу, следуя инструкциям по ссылке -

http://www.thinkplexx.com/learn/howto/security/ssl/remove-passphrase-password-from-private-rsa-key

person senchaDev    schedule 06.11.2014

Вам необходимо предоставить аутентификацию. Либо сделайте это, используя обычный текст и заполнив его в конфигурации или командной строке, либо используйте для этого сертификат ssh-public-key.

Здесь вы можете найти руководство о том, как подключить его к GitHub, и я думаю, что вы должны сделать то же самое самостоятельно git-сервер.

person Highmastdon    schedule 30.10.2014
comment
У меня уже есть файлы id_rsa, id_rsa.pub и known_hosts в моей локальной системе. Где я должен предоставить аутентификацию в Jenkins? - person senchaDev; 30.10.2014
comment
Вам нужно проверить, какой пользователь jenkins работает в качестве теста, как этот пользователь. Для меня в Linux это будет сам пользователь Jenkins, поэтому я должен установить файлы ключей id_rsa в нужном месте для этого пользователя, а именно: home/jenkins/.ssh - person MadManMonty; 30.10.2014
comment
Пользователь, выполняющий команду git clone, должен отправить свой (открытый) ssh-ключ на сервер git. - person Highmastdon; 30.10.2014

просто перейдите в jenkins -> глобальная конфигурация инструмента -> добавить git -> имя (по умолчанию) и путь к исполняемому файлу Git (git) -> сохранить

person ashok    schedule 28.04.2021