From 3b6780360c8306699b66519a1307af3cd4119673 Mon Sep 17 00:00:00 2001 From: Nana Janashia Date: Wed, 7 Apr 2021 12:04:09 +0200 Subject: [PATCH] Create ansible server env var --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e8c5ae2..ba45f7f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,18 @@ pipeline { agent any + environment { + ANSIBLE_SERVER = "167.99.136.157" + } stages { stage("copy files to ansible server") { steps { script { echo "copying all neccessary files to ansible control node" sshagent(['ansible-server-key']) { - sh "scp -o StrictHostKeyChecking=no ansible/* root@167.99.136.157:/root" + sh "scp -o StrictHostKeyChecking=no ansible/* root@${ANSIBLE_SERVER}:/root" withCredentials([sshUserPrivateKey(credentialsId: 'ec2-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]) { - sh 'scp $keyfile root@167.99.136.157:/root/ssh-key.pem' + sh 'scp $keyfile root@$ANSIBLE_SERVER:/root/ssh-key.pem' } } } @@ -21,7 +24,7 @@ pipeline { echo "calling ansible playbook to configure ec2 instances" def remote = [:] remote.name = "ansible-server" - remote.host = "167.99.136.157" + remote.host = ANSIBLE_SERVER remote.allowAnyHosts = true withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){