From 49d635b79a2cd907a6335c7618ca9e1d51cf7270 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 2 Apr 2026 11:24:04 -0500 Subject: [PATCH] Refactor Jenkinsfile to improve SSH known hosts handling. Introduced a variable for the development server host and updated the known hosts file path, enhancing security and maintainability during deployment processes. --- Jenkinsfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 956c454c..321fead5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -248,19 +248,20 @@ pipeline { ) ]) { script { + def devHost = env.DEV_SERVER_HOST?.trim() + def knownHostsFile = "${env.WORKSPACE}/.jenkins-anexo76-known_hosts" sh """ set -euo pipefail - mkdir -p ~/.ssh - chmod 700 ~/.ssh - ssh-keyscan -T 15 -H '${env.DEV_SERVER_HOST}' >> ~/.ssh/known_hosts + ssh-keyscan -T 15 -H '${devHost}' > '${knownHostsFile}' """ def remote = [ name: 'dev-server', - host: env.DEV_SERVER_HOST, + host: devHost, user: env.DEV_SERVER_USER ?: env.DEV_SERVER_SSH_USER, identityFile: env.DEV_SERVER_KEY, passphrase: env.DEV_SERVER_KEY_PASSPHRASE, - allowAnyHosts: false + allowAnyHosts: false, + knownHosts: knownHostsFile ] sshCommand remote: remote, command: ''' set -euo pipefail