Add jenkinsfile for ansible execution

This commit is contained in:
Nana Janashia
2021-04-07 11:24:55 +02:00
parent 851ef30959
commit 9573355ec3
4 changed files with 56 additions and 28 deletions

37
Jenkinsfile vendored
View File

@@ -1,36 +1,17 @@
def gv
pipeline {
agent any
stages {
stage("init") {
stage("copy files to ansible server") {
steps {
script {
gv = load "script.groovy"
}
}
}
stage("build jar") {
steps {
script {
echo "building jar"
//gv.buildJar()
}
}
}
stage("build image") {
steps {
script {
echo "building image"
//gv.buildImage()
}
}
}
stage("deploy") {
steps {
script {
echo "deploying"
//gv.deployApp()
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"
withCredentials([sshUserPrivateKey(credentialsId: 'ec2-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]) {
sh "scp ${keyfile} root@167.99.136.157:/root/ssh-key.pem"
}
}
}
}
}