-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
60 lines (57 loc) · 1.96 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
55
56
57
58
59
60
node('dko-personal') {
def image
stage('Build') {
echo 'Building..'
checkout scm
sh '''
# Get an unique venv folder to using *inside* workspace
VENV=".venv-$BUILD_NUMBER"
# Initialize new venv
virtualenv "$VENV"
# Update pip
PS1="${PS1:-}" . "$VENV/bin/activate"
#install requirements
pip install -r requirements.txt
python manage.py migrate # Apply Souths database migrations
#python manage.py compilemessages # Create translation files
python manage.py collectstatic --noinput # Collect static files
'''
}
stage('Test') {
sh '''
VENV=".venv-$BUILD_NUMBER"
PS1="${PS1:-}" . "$VENV/bin/activate"
python manage.py test --noinput
'''
}
stage('Deploy') {
if (! fileExists("/webapps/$JOB_NAME")) {
sh '''
mkdir -p "/webapps/$JOB_NAME"
'''
} else {
dir("/webapps/$JOB_NAME") {
sh '''
tar cfv "../archive_$JOB_NAME-$BUILD_NUMBER.tar" ./
rm -rf ./*
'''
}
}
dir("/webapps/$JOB_NAME") {
// some block
checkout scm
if (! fileExists('.venv')) {
sh 'virtualenv .venv'
}
sh '''
PS1="${PS1:-}" . ".venv/bin/activate"
#install requirements
pip install -r requirements.txt
python manage.py migrate # Apply Souths database migrations
python manage.py compilemessages # Create translation files
python manage.py collectstatic --noinput # Collect static files
'''
echo "Please restart gunicorn & co"
}
}
}