From 3b14e9829e5f9b0671b4f6cf6ffe5a40acda706f Mon Sep 17 00:00:00 2001 From: vgallegoiz Date: Sun, 5 May 2024 20:18:20 +0200 Subject: [PATCH] Test Jenkinsfile --- Jenkinsfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5717c9c..92d1889 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,18 @@ pipeline { agent any + environment { SSH_CREDENTIALS_ID = 'SSH' + GIT_CREDENTIALS_ID = 'Gitea-user' } stages { stage('Checkout') { steps { - // Hace un checkout del repositorio Git - git 'ssh://git@gitssh.mainserverprivate.org:8222/vgallegoiz/Status.git' + // Hace un checkout del repositorio Git utilizando las credenciales de Git + withCredentials([usernamePassword(credentialsId: '${GIT_CREDENTIALS_ID}', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) { + git credentialsId: '${GIT_CREDENTIALS_ID}', url: 'ssh://git@gitssh.mainserverprivate.org:8222/vgallegoiz/Status.git' + } } } @@ -16,7 +20,9 @@ pipeline { steps { // Ejecuta un Git Pull en el servidor remoto script { - sh 'ssh usuario@192.168.1.39 "cd /home/userpi/Status && git pull"' + sshagent(credentials: ['${SSH_CREDENTIALS_ID}']) { + sh 'ssh usuario@192.168.1.39 "cd /home/userpi/Status && git pull"' + } } } }