-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
54 lines (51 loc) · 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!groovy
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
slackSend color: "warning", message: "Started `${env.JOB_NAME}#${env.BUILD_NUMBER}`"
}
}
stage('Setup environment') {
steps {
sh '. /var/lib/jenkins/workspace/.virtualenvs/api/bin/activate'
sh '/var/lib/jenkins/workspace/.virtualenvs/api/bin/pip install -r requirements.txt'
sh '/var/lib/jenkins/workspace/.virtualenvs/api/bin/python3 manage.py makemigrations --noinput'
sh '/var/lib/jenkins/workspace/.virtualenvs/api/bin/python3 manage.py migrate --noinput'
}
}
stage('Test') {
steps {
sh "flake8 --exclude='manage.py, voxpopapi/settings.py, migrations, templates, */models.py, */tests.py, */admin.py, provision, nginx, docs, setup.py' ."
sh "/var/lib/jenkins/workspace/.virtualenvs/api/bin/coverage run --source='.' --omit=voxpopapi/celery.py,voxpopapi/wsgi.py,api/migrations/*,api/tasks.py,api/apps.py manage.py test api"
sh '/var/lib/jenkins/workspace/.virtualenvs/api/bin/coverage report'
}
}
stage('Homologation deploy') {
when {
branch 'dev'
}
steps {
sh 'ansible-playbook -i provision/hosts provision/hml/deploy.yml'
}
}
stage('Production deploy') {
when {
branch 'master'
}
steps {
sh 'ansible-playbook -i provision/hosts provision/prod/deploy.yml'
}
}
}
post {
success {
slackSend color: "good", message: "Build successful: `${env.JOB_NAME}#${env.BUILD_NUMBER}` <${env.BUILD_URL}|Open in Jenkins>"
}
failure {
slackSend color: "danger", message: "Build failed :face_with_head_bandage: \n`${env.JOB_NAME}#${env.BUILD_NUMBER}` <${env.BUILD_URL}|Open in Jenkins>"
}
}
}