Задание выпуска релиза Jenkins в Windows не выполняется в команде Git push
Я создаю Jenkins Job для Windows, чтобы автоматизировать процесс выпуска. Поэтому я использую плагин релиза Maven.
Когда я выполняю Perform Maven Release на работе, он запрашивает у меня имя входа SCM, префикс комментария SCM и тег SCM. Но задание не выполняется при выполнении git push для фиксации изменений со следующими журналами.
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\windows\TEMP\maven-scm-1948138390.commit pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git push git@github.com:elizabetht/StudentEnrollmentWithREST.git master:master"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:03.980s
[INFO] Finished at: Mon Feb 03 14:29:30 CST 2014
[INFO] Final Memory: 9M/21M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release- plugin:2.2.2:prepare (default-cli) on project StudentEnrollmentWithREST: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts\pom.xml to com.github.elizabetht/StudentEnrollmentWithREST/1.3-SNAPSHOT/StudentEnrollmentWithREST-1.3-SNAPSHOT.pom
[ERROR] Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
channel stopped
Finished: FAILURE
Я считаю, что эта ошибка связана с запуском агента ssh для работы Дженкинса. Я следовал решению, приведенному в вопросе StaverOverflow Maven - Ошибка высвобождения кода для GitHub (зависает после Push), и git push отлично работает в терминале.
Настройки параметров SCM в pom.xml следующие
<scm>
<connection>scm:git:git@github.com:elizabetht/StudentEnrollmentWithREST.git</connection>
<developerConnection>scm:git:git@github.com:elizabetht/StudentEnrollmentWithREST.git</developerConnection>
<url>http://github.com/elizabetht/StudentEnrollmentWithREST</url>
</scm>
Вывод mvn scm:validate выглядит следующим образом
$ mvn scm:validate
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building StudentEnrollmentWithREST 1.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-scm-plugin:1.9:validate (default-cli) @ StudentEnrollmentWithREST >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-maven) @ StudentEnrollmentWithREST ---
[INFO]
[INFO] <<< maven-scm-plugin:1.9:validate (default-cli) @ StudentEnrollmentWithREST <<<
[INFO]
[INFO] --- maven-scm-plugin:1.9:validate (default-cli) @ StudentEnrollmentWithREST ---
[INFO] connectionUrl scm connection string is valid.
[INFO] project.scm.connection scm connection string is valid.
[INFO] project.scm.developerConnection scm connection string is valid.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.325s
[INFO] Finished at: Tue Feb 04 18:06:04 CST 2014
[INFO] Final Memory: 14M/309M
[INFO] ------------------------------------------------------------------------
Добавление вывода "ssh -vT git@github.com"
C:\Users\Sara>ssh -vT git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to github.com [192.30.252.131] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Sara/.ssh/identity type -1
debug1: identity file /c/Users/Sara/.ssh/id_rsa type 1
debug1: identity file /c/Users/Sara/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Ope
n-5ubuntu1+github5
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1+github5 pat OpenSSH
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/Sara/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Sara/.ssh/identity
debug1: Offering public key: /c/Users/Sara/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: client_input_channel_req: channel 0 rtype exit-status re
Hi elizabetht! You've successfully authenticated, but GitHub doe
ell access.
debug1: channel 0: free: client-session, nchannels 1
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 se
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 1
Может ли кто-нибудь помочь с указателями на то, как заставить это работать как работа Дженкинса в Windows?
2 ответа
Чтобы добавить к ответу /questions/1144989/zadanie-vyipuska-reliza-jenkins-v-windows-ne-vyipolnyaetsya-v-komande-git-push/1144999#1144999, всегда проверяйте журналы jenkins на наличие более подробной ошибки. Спасибо Элизабет ( elizabetht) за упоминание меня в этом посте!
Я воспользовался обходным путем, найденным @Saravana Kumar Periyasamy в теме "Возможные проблемы между Дженкинсом и Github" по ссылке https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
Принудительно запустив Jenkins как пользователь с настроенным ключом SSH, загрузив ключ SSH, сгенерированный без ключевой фразы и альта, я успешно выполнил Maven Release с использованием Jenkins (после 116 попыток выяснить правильную конфигурацию с помощью этого задания Jenkins!!)
Вот вывод с консоли
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\Users\Sara\AppData\Local\Temp\maven-scm-170370981.commit pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git push git@github.com:elizabetht/StudentEnrollmentWithREST.git master:master"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Tagging release with the label StudentEnrollmentWithREST-1.3...
[INFO] Executing: cmd.exe /X /C "git tag -F C:\Users\Sara\AppData\Local\Temp\maven-scm-1647501295.commit StudentEnrollmentWithREST-1.3"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git push git@github.com:elizabetht/StudentEnrollmentWithREST.git StudentEnrollmentWithREST-1.3"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git ls-files"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Transforming 'StudentEnrollmentWithREST'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\Users\Sara\AppData\Local\Temp\maven-scm-890096458.commit pom.xml"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Executing: cmd.exe /X /C "git push git@github.com:elizabetht/StudentEnrollmentWithREST.git master:master"
[INFO] Working directory: C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts
[INFO] Release preparation complete.
И затем работа приступила к загрузке моих артефактов в мой репозиторий релизов.
Элементы в pom.xml следующие (это сработало)
<scm>
<connection>scm:git:git@github.com:user/repo-name.git</connection>
<developerConnection>scm:git:git@github.com:user/repo-name.git</developerConnection>
<url>git@github.com:user/repo-name.git</url>
<tag>HEAD</tag>
</scm>
В своей конфигурации задания Jenkins я указал URL-адрес хранилища в следующем формате
git@github.com:user/repo-name.git
вместо использования https://github.com/user/reponame.git
Все шаги, которые я выполнил, чтобы заставить релиз Maven работать через Jenkins, доступны по http://elizabetht.github.io/blog/2014/02/05/jenkins-release-upload/