Таким образом, я использовал конвейер сценариев Jenkins groovy с некоторыми сценариями оболочки для извлечения хранилища кода. Затем он запускает несколько тестов, упаковывает код и затем переключается в новую папку и извлекает второй репозиторий git.
Пока все хорошо, довольно просто:
git url: 'git@gitlab:platform-automation.git', credentialsId: '12345678', branch: "${gitbranch}"
Раньше (согласно журналу заданий) извлекал новую ветку с помощью "git checkout -b feature / new-branch"
Код был недавно подвергнут рефакторингу, чтобы позволить ему возвращаться в GitLab с некоторым статусом сборки и теперь больше не проверяет ветку:
Cloning repository git@gitlab:platform-automation.git
> git init /var/lib/jenkins/workspace/Package-for-Deployment/platform # timeout=10
Fetching upstream changes from git@gitlab:platform-automation.git
> git --version # timeout=10
using GIT_SSH to set credentials This key is used to access GitLab repositories
> git fetch --tags --progress git@gitlab:platform-automation.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url git@gitlab:platform-automation.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url git@gitlab:platform-automation.git # timeout=10
Fetching upstream changes from git@gitlab:platform-automation.git
using GIT_SSH to set credentials This key is used to access GitLab repositories
> git fetch --tags --progress git@gitlab:platform-automation.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/feature/new-branch^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/feature/new-branch^{commit} # timeout=10
> git rev-parse origin/feature/new-branch^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Странно, подумал я, давайте вернемся к старому коду, используя git revert, тот же результат.
Итак, давайте попробуем удалить переменную $ {gitbranch} и использовать это:
git url: 'git@gitlab:platform-automation.git', credentialsId: '12345678', branch: 'develop'
Затем на следующей строке добавьте строку в скрипт оболочки, которая говорит следующее (что плагин делал в любом случае):
git checkout -b ${gitbranch}
Теперь новая ветка извлекается, и работа продолжается, как и ожидалось.
Почему у плагина Jenkins git pipe теперь есть проблема с проверкой ветки с помощью переменной?