-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
40 lines (40 loc) · 1.57 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
pipeline {
agent any
stages {
stage('Testing') {
steps {
sh "/home/jenkins/.local/bin/pytest API1"
sh "/home/jenkins/.local/bin/pytest API2"
sh "/home/jenkins/.local/bin/pytest API3"
sh "/home/jenkins/.local/bin/pytest Main"
}
}
stage('Build Artifacts') {
steps {
sh "docker-compose build"
sh "docker-compose push"
}
}
stage('Deploy to Prod') {
steps {
sh "/home/jenkins/.local/bin/ansible-playbook -i ansible/inventory ansible/playbook.yaml"
sh "echo BUILD_NUMBER=${BUILD_NUMBER} > .env"
sh "echo PROD_SKEY=${PROD_SKEY} > .env"
sh "echo PROD_DB_URI=${PROD_DB_URI} > .env"
sh "scp docker-compose.yml jenkins@manager:/home/jenkins/docker-compose.yaml"
sh "scp .env jenkins@manager:/home/jenkins/.env"
script {
sh """ssh -i /home/jenkins/.ssh/id_rsa manager << EOF
env BUILD_NUMBER=${BUILD_NUMBER}
export BUILD_NUMBER=${BUILD_NUMBER}
export PROD_SKEY=${PROD_SKEY}
export PROD_DB_URI=${PROD_DB_URI}
docker stack deploy --compose-file /home/jenkins/docker-compose.yaml stack
exit
EOF"""
}
//sh "docker stack deploy --compose-file /home/jenkins/docker-compose.yaml stack"
}
}
}
}