Add copying to remote

This commit is contained in:
Nana Janashia
2021-04-03 17:53:39 +02:00
parent c727d27e81
commit f5aa1df5d3

View File

@@ -1,12 +1,16 @@
pipeline { pipeline {
agent any agent any
environment {
ANSIBLE_SERVER = "157.230.120.252"
}
stages { stages {
stage("copy playbook to ansible-server") { stage("copy playbook to ansible-server") {
steps { steps {
script { script {
echo "copying ansible folder to ansible server" 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 = [:] def remote = [:]
remote.name = "ansible-server" remote.name = "ansible-server"
remote.host = "157.230.120.252" remote.host = ANSIBLE_SERVER
remote.allowAnyHosts = true remote.allowAnyHosts = true
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) { withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) {
remote.identityFile = identity remote.identityFile = identity
remote.user = user remote.user = user
stage('Remote SSH') {
sshCommand remote: remote, command: "ls -l" sshCommand remote: remote, command: "ls -l"
}
} }
} }
} }