pipeline { agent any environment { withCredentials([usernamePassword(credentialsId: 'QuizServerCreds', usernameVariable: 'USERNAME', passwordVariable: 'SERVER_IP')]) { SERVER_USERNAME = "${USERNAME}" SERVER_IP = "${SERVER_IP}" } } stages { stage('Copy Files on Server') { steps { sh 'ssh-keyscan ${SERVER_IP} > ~/.ssh/known_hosts' sh 'rsync -avzhe --exclude 'Jenkinsfile' ssh * ${SERVER_USERNAME}@${SERVER_IP}:/var/www/public_html' } } } }