From f5aa1df5d3a53b85ea8b2b6cec26a7de1fbc1453 Mon Sep 17 00:00:00 2001 From: Nana Janashia Date: Sat, 3 Apr 2021 17:53:39 +0200 Subject: [PATCH] Add copying to remote --- Jenkinsfile-v1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile-v1 b/Jenkinsfile-v1 index d7b790e..a4a9c3a 100644 --- a/Jenkinsfile-v1 +++ b/Jenkinsfile-v1 @@ -1,12 +1,16 @@ pipeline { agent any + environment { + ANSIBLE_SERVER = "157.230.120.252" + } stages { stage("copy playbook to ansible-server") { steps { script { echo "copying ansible folder to ansible server" - - + withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) { + sh "scp -i ${identity} ansible/ansible.cfg ${ANSIBLE_SERVER}:/root" + } } } } @@ -25,15 +29,14 @@ pipeline { def remote = [:] remote.name = "ansible-server" - remote.host = "157.230.120.252" + remote.host = ANSIBLE_SERVER remote.allowAnyHosts = true withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) { remote.identityFile = identity remote.user = user - stage('Remote SSH') { - sshCommand remote: remote, command: "ls -l" - } + + sshCommand remote: remote, command: "ls -l" } } }