Jenkins сообщает о сбое разрешения при извлечении субмодуля с помощью плагина Git (Bitbucket удаленного репо) - PullRequest
0 голосов
/ 21 февраля 2020

У меня есть проект в Bitbucket (облачном хранилище), который я создаю вместе с Jenkins (размещенный на премьере). В проекте есть субмодуль. Если я проигнорирую субмодуль, задание (в Дженкинсе) будет успешным. Если я пытаюсь обновить субмодуль, я получаю это любовное замечание:

stderr: Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Полный справочник заданий с моей конфигурацией SCM приведен ниже для справки.

Мы используем пароль приложения в Bitbucket для доступа к хранилищу.

То, что я пробовал ...

  1. Обновление Git Плагин до v4.1.1 - для Дженкинс конвейер git Обновление подмодуля команды
  2. Создано отдельное задание для извлечения репо подмодуля с использованием тех же учетных данных. Я смог вытащить репо из Jenkins, используя те же учетные данные, что и проблемная работа c без проблем.
  3. Подмодуль находится в каталоге lambda / messages; это правильно

Содержимое файла .gitmodules моего проекта ...

[submodule "lambda/messages"]
        path = lambda/messages
        url = git@bitbucket.org:myCompany/myRespository.git

Вывод из задания Jenkins ...

Started by user myUser
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Started by user myUser
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\myRespository
using credential Bitbucket
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://myUser@bitbucket.org/myCompany/deco4-aws.git # timeout=10
Fetching upstream changes from https://myUser@bitbucket.org/myCompany/deco4-aws.git
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Bitbucket App password for Jenkins
> git.exe fetch --tags --progress -- https://myUser@bitbucket.org/myCompany/deco4-aws.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision cecc872074937f981a9c593b931440b320b2ea32 (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f cecc872074937f981a9c593b931440b320b2ea32 # timeout=10
Commit message: "PS-2315: added thing vars/api/lambda"
> git.exe rev-list --no-walk cecc872074937f981a9c593b931440b320b2ea32 # timeout=10
> git.exe remote # timeout=10
> git.exe submodule init # timeout=10
> git.exe submodule sync # timeout=10
> git.exe config --get remote.origin.url # timeout=10
> git.exe submodule init # timeout=10
> git.exe config -f .gitmodules --get-regexp ^submodule\.(.+)\.url # timeout=10
> git.exe config --get submodule.lambda/messages.url # timeout=10
> git.exe remote # timeout=10
> git.exe config --get remote.origin.url # timeout=10
> git.exe config -f .gitmodules --get submodule.lambda/messages.path # timeout=10
using GIT_ASKPASS to set credentials Bitbucket App password for Jenkins
> git.exe submodule update --init --recursive lambda/messages # timeout=10
hudson.plugins.git.GitException: Command "git.exe submodule update --init --recursive lambda/messages" returned status code 1:
stdout: 
stderr: Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@bitbucket.org:myCompany/deco4-messaging.git' into submodule path 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages' failed
Failed to clone 'lambda/messages'. Retry scheduled
Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@bitbucket.org:myCompany/deco4-messaging.git' into submodule path 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages' failed
Failed to clone 'lambda/messages' a second time, aborting
using credential Bitbucket
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://myUser@bitbucket.org/myCompany/deco4-aws.git # timeout=10
Fetching upstream changes from https://myUser@bitbucket.org/myCompany/deco4-aws.git
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Bitbucket App password for Jenkins
> git.exe fetch --tags --progress -- https://myUser@bitbucket.org/myCompany/deco4-aws.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision cecc872074937f981a9c593b931440b320b2ea32 (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f cecc872074937f981a9c593b931440b320b2ea32 # timeout=10
Commit message: "PS-3176: added more things vars/api/lambda"
> git.exe rev-list --no-walk cecc872074937f981a9c593b931440b320b2ea32 # timeout=10
> git.exe remote # timeout=10
> git.exe submodule init # timeout=10
> git.exe submodule sync # timeout=10
> git.exe config --get remote.origin.url # timeout=10
> git.exe submodule init # timeout=10
> git.exe config -f .gitmodules --get-regexp ^submodule\.(.+)\.url # timeout=10
> git.exe config --get submodule.lambda/messages.url # timeout=10
> git.exe remote # timeout=10
> git.exe config --get remote.origin.url # timeout=10
> git.exe config -f .gitmodules --get submodule.lambda/messages.path # timeout=10
using GIT_ASKPASS to set credentials Bitbucket App password for Jenkins
> git.exe submodule update --init --recursive lambda/messages # timeout=10
hudson.plugins.git.GitException: Command "git.exe submodule update --init --recursive lambda/messages" returned status code 1:
stdout: 
stderr: Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@bitbucket.org:myCompany/deco4-messaging.git' into submodule path 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages' failed
Failed to clone 'lambda/messages'. Retry scheduled
Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@bitbucket.org:myCompany/deco4-messaging.git' into submodule path 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages' failed
Failed to clone 'lambda/messages' a second time, aborting

Задание Jenkins Конфигурация SCM ...

Git Configuration in Job

Исчезли идеи по поводу root. Любое руководство приветствуется.

1 Ответ

0 голосов
/ 21 февраля 2020

Доступ к субмодулю осуществлялся через S SH, в то время как родительский HTTPS.

Субмодуль ...

[submodule "lambda/messages"]
        path = lambda/messages
        url = git@bitbucket.org:myCompany/myRespository.git

Родительский репо ...

enter image description here

Поскольку у меня не было настроено ни одного ключа S SH, Дженкинс мог выполнять аутентификацию при клонировании подмодуля. И теперь ошибка имеет смысл:

stderr: Cloning into 'C:/Program Files (x86)/Jenkins/workspace/my.repository/lambda/messages'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Чтобы исправить, я перенастроил субмодуль в хранилище для доступа к его удаленному репо через https. Изменения были внесены путем редактирования файла ./.gitmodules в root хранилища.

[submodule "lambda/messages"]
    path = lambda/messages
    url = https://myUser@bitbucket.org/myCompany/myRepository.git

Следующая сборка прошла успешно, как нужно.

Надеюсь, это кому-нибудь поможет!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...