-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
53 lines (51 loc) · 1.64 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
pipeline {
agent any
environment {
TEMP_DIR="/tmp/${env.JOB_NAME}/${env.ghprbActualCommit}"
}
stages {
stage('Setting up env') {
steps {
echo "[[ Start virtual environment ]]"
sh """
echo "[ Current directory ] : " `pwd`
echo "[ Environment Variables ] "
env
# Each stage needs custom setting done again. By default /bin/python is used.
source /home/qcadmin/py310/bin/activate
mkdir -p $TEMP_DIR
python -m venv $TEMP_DIR/venv
# activate new virtual env
source $TEMP_DIR/venv/bin/activate
echo "[ Python used ] : " `which python`
cd ${env.WORKSPACE}
echo "[ Install dependencies ]"
pip install -r requirements.txt
"""
}
}
stage('Run regression tests') {
steps {
echo '[[ Run pytest ]]'
sh """
# activate virtual environment again
source $TEMP_DIR/venv/bin/activate
echo "[ Python used ] : " `which python`
cd ${env.WORKSPACE}
echo "[ Installing ${env.JOB_NAME} ]"
python setup.py install
echo "[ Run test now ]"
pytest --black
"""
}
}
}
post {
always {
echo 'Tear down the environments'
sh """
rm -rf $TEMP_DIR
"""
}
}
}