try today...
This commit is contained in:
parent
9ceeddfd14
commit
0576d77dfa
|
@ -1,9 +1,4 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
// environment {
|
|
||||||
// remote = [:]
|
|
||||||
// withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', usernameVariable: 'username')]) {
|
|
||||||
// remote.user = $userName
|
|
||||||
|
|
||||||
agent {
|
agent {
|
||||||
label 'pi501.in.thelinuxpro.net'
|
label 'pi501.in.thelinuxpro.net'
|
||||||
}
|
}
|
||||||
|
@ -23,63 +18,58 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
|
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
|
||||||
def remote = [:]
|
|
||||||
remote.name = "pi501.in.thelinuxpro.net"
|
|
||||||
remote.host = "pi501.in.thelinuxpro.net"
|
|
||||||
remote.allowAnyHosts = true
|
|
||||||
remote.user = $userName
|
|
||||||
remote.identityFile = $identity
|
|
||||||
|
|
||||||
sh 'echo $remote'
|
def transferFileCommand_pi501 = sh(
|
||||||
sh 'echo $remote.user'
|
script: "scp -r -i ${identity} -o StrictHostKeyChecking=no nrpe ${userName}@pi501.in.thelinuxpro.net:/tmp/",
|
||||||
sh 'echo $remote.identityFile'
|
returnStdout: true
|
||||||
sh 'echo $userName'
|
).trim()
|
||||||
sh 'echo $identity'
|
|
||||||
sshPut remote: remote, from: 'nrpe', into: '/tmp'
|
|
||||||
sshCommand remote: remote, command: 'cd /tmp/nrpe/; chmod +x setup.sh; sudo ./setup.sh'
|
|
||||||
sshRemove remote: remote, path: '/tmp/nrpe'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
script {
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
|
|
||||||
def remote = [:]
|
|
||||||
remote.name = "pi502.in.thelinuxpro.net"
|
|
||||||
remote.host = "pi502.in.thelinuxpro.net"
|
|
||||||
remote.allowAnyHosts = true
|
|
||||||
remote.user = userName
|
|
||||||
remote.identityFile = identity
|
|
||||||
|
|
||||||
sshPut remote: remote, from: 'nrpe', into: '/tmp'
|
def transferFileCommand_pi502 = sh(
|
||||||
sshCommand remote: remote, command: 'cd /tmp/nrpe/; chmod +x setup.sh; sudo ./setup.sh'
|
script: "scp -r -i ${identity} -o StrictHostKeyChecking=no nrpe ${userName}@pi502.in.thelinuxpro.net:/tmp/",
|
||||||
sshRemove remote: remote, path: '/tmp/nrpe'
|
returnStdout: true
|
||||||
}
|
).trim()
|
||||||
}
|
|
||||||
script {
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
|
|
||||||
def remote = [:]
|
|
||||||
remote.name = "pi503.in.thelinuxpro.net"
|
|
||||||
remote.host = "pi503.in.thelinuxpro.net"
|
|
||||||
remote.allowAnyHosts = true
|
|
||||||
remote.user = userName
|
|
||||||
remote.identityFile = identity
|
|
||||||
|
|
||||||
sshPut remote: remote, from: 'nrpe', into: '/tmp'
|
def transferFileCommand_pi503 = sh(
|
||||||
sshCommand remote: remote, command: 'cd /tmp/nrpe/; chmod +x setup.sh; sudo ./setup.sh'
|
script: "scp -r -i ${identity} -o StrictHostKeyChecking=no nrpe ${userName}@pi503.in.thelinuxpro.net:/tmp/",
|
||||||
sshRemove remote: remote, path: '/tmp/nrpe'
|
returnStdout: true
|
||||||
}
|
).trim()
|
||||||
}
|
|
||||||
script {
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
|
|
||||||
def remote = [:]
|
|
||||||
remote.name = "pi504.in.thelinuxpro.net"
|
|
||||||
remote.host = "pi504.in.thelinuxpro.net"
|
|
||||||
remote.allowAnyHosts = true
|
|
||||||
remote.user = userName
|
|
||||||
remote.identityFile = identity
|
|
||||||
|
|
||||||
sshPut remote: remote, from: 'nrpe', into: '/tmp'
|
def transferFileCommand_pi504 = sh(
|
||||||
sshCommand remote: remote, command: 'cd /tmp/nrpe/; chmod +x setup.sh; sudo ./setup.sh'
|
script: "scp -r -i ${identity} -o StrictHostKeyChecking=no nrpe ${userName}@pi504.in.thelinuxpro.net:/tmp/",
|
||||||
sshRemove remote: remote, path: '/tmp/nrpe'
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
echo "File Transferred to remote server: ${transferFileCommand_pi501}"
|
||||||
|
echo "File Transferred to remote server: ${transferFileCommand_pi502}"
|
||||||
|
echo "File Transferred to remote server: ${transferFileCommand_pi503}"
|
||||||
|
echo "File Transferred to remote server: ${transferFileCommand_pi504}"
|
||||||
|
|
||||||
|
def remoteCommand = "cd /tmp/nrpe ; chmod +x setup.sh; ./setup.sh"
|
||||||
|
|
||||||
|
def sshCmd_pi501 = sh(
|
||||||
|
script: "ssh -i ${identity} -o StrictHostKeyChecking=no -l ${userName} pi501.in.thelinuxpro.net 'sudo bash -c \"${remoteCommand}\"'",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
def sshCmd_pi502 = sh(
|
||||||
|
script: "ssh -i ${identity} -o StrictHostKeyChecking=no -l ${userName} pi502.in.thelinuxpro.net 'sudo bash -c \"${remoteCommand}\"'",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
def sshCmd_pi503 = sh(
|
||||||
|
script: "ssh -i ${identity} -o StrictHostKeyChecking=no -l ${userName} pi503.in.thelinuxpro.net 'sudo bash -c \"${remoteCommand}\"'",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
def sshCmd_pi504 = sh(
|
||||||
|
script: "ssh -i ${identity} -o StrictHostKeyChecking=no -l ${userName} pi504.in.thelinuxpro.net 'sudo bash -c \"${remoteCommand}\"'",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
echo "Command executed on remote server: ${sshCmd_pi501}"
|
||||||
|
echo "Command executed on remote server: ${sshCmd_pi502}"
|
||||||
|
echo "Command executed on remote server: ${sshCmd_pi503}"
|
||||||
|
echo "Command executed on remote server: ${sshCmd_pi504}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue