Jenkins se congela al hacer “git checkout” en las credenciales para LFS.
Tengo un Pipeline de varias ramas basado en un archivo de Jenkins que clona explícitamente otro repositorio proporcionado por parámetros. Veo que se congela y agota el tiempo después de intentar solicitar credenciales para git-lfs
como parte del comando git checkout -f <HASH>
.
¿Cómo puedo hacer checkout de un repositorio con acceso a git-lfs con credenciales?
Jenkinsfile:
stages {
stage('Fetch Source Code') {
steps{
dir('repo') {
git branch: "${params.Branch}", credentialsId: 'git-creds', url: "${params.RepoURL}"
}
}
}
}
Consola de Jenkins:
“`
<blockquote>
git init /home/jenkins/agent/workspace/<pipeline_name>/repo # timeout=10
Fetching upstream changes from <https_private_gitlab_url>
git –version # timeout=10
git –version # 'git version 2.30.2'
utilizando GIT_ASKPASS para establecer credenciales para acceder a los recursos git
git fetch –tags –force –progress — <https_private_gitlab_url> +refs/heads/<em>:refs/remotes/origin/</em> # timeout=10
Evitar segunda búsqueda
Checking out Revision HASH (refs/remotes/origin/master)
git config remote.origin.url <https_private_gitlab_url> # timeout=10
git config –add remote.origin.fetch +refs/heads/<em>:refs/remotes/origin/</em> # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git config core.sparsecheckout # timeout=10
git checkout -f <hash> # timeout=10
Agota el tiempo
“`
davy.ai
Para hacer checkout de un repositorio con acceso a git lfs con credenciales, puedes agregar los siguientes pasos a tu Jenkinsfile antes del comando
git checkout -f <hash>
:Esto instalará
git lfs
si aún no está instalado, configurará las credenciales paragit lfs
, descargarán los objetos LFS y finalmente hará checkout de la revisión requerida. Las variables de entornoGIT_LFS_USERNAME
yGIT_LFS_PASSWORD
se llenarán con las credenciales almacenadas en el ID de credencialesgit-lfs-creds
. Asegúrate de reemplazargit-lfs-creds
con el ID real de tus credenciales de Git LFS en Jenkins.