From c6589989d461e3f10ec17b94238c0dcd70c3433f Mon Sep 17 00:00:00 2001
From: Juan Ferrer Toribio <juan@verdnatura.es>
Date: Fri, 5 Jul 2024 11:11:29 +0200
Subject: [PATCH] ci: refs #7643 Reprepro SSH credentials fix

---
 Jenkinsfile | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index b79a0eaa..175df796 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -52,20 +52,22 @@ pipeline {
             }
             steps {
                 unstash 'debuildOutput'
+
                 script {
                     debFile = sh(script: 'ls output/*.deb', returnStdout: true).trim()
-                }
 
-                withCredentials([sshUserPrivateKey(
-                    credentialsId: 'jenkins-agent',
-                    usernameVariable: 'user',
-                    keyFileVariable: 'identityFile'
-                )]) {
                     remote.name = 'reprepro'
                     remote.host = 'reprepro.reprepro'
                     remote.allowAnyHosts = true
-                    remote.user = user
-                    remote.identityFile = identityFile
+
+                    withCredentials([sshUserPrivateKey(
+                        credentialsId: 'jenkins-agent',
+                        usernameVariable: 'user',
+                        keyFileVariable: 'identityFile'
+                    )]) {
+                        remote.user = user
+                        remote.identityFile = identityFile
+                    }
                 }
 
                 sshPut([