-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjenkinsfile
90 lines (79 loc) · 1.86 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
pipeline {
agent {
kubernetes {
inheritFrom 'base'
yaml '''
spec:
containers:
- name: python
image: qiaoshilu/devops-kse-python:v3.5.0
command: [\'sleep\']
args: [\'1d\']
'''
label 'default'
}
}
stages {
stage('拉取测试代码') {
steps {
container('python') {
git(url: 'https://github.com/kubesphere-sigs/Api-AutoTest.git', branch: 'master', changelog: true, poll: false)
}
}
}
stage('安装三方python依赖') {
steps {
container('python') {
sh '''
python3 -m pip install --upgrade pip
pip install -r requirements.txt
'''
}
}
}
stage('运行测试脚本') {
agent none
environment {
// 使用apiserver的dns地址
ENV_URL = "172.31.53.27:30464"
PATH = "$PATH:/usr/local/src/allure-2.17.2/bin"
}
steps {
container('python') {
script {
try {
sh '''
envsubst < ${WORKSPACE}/config/config.yaml > ${WORKSPACE}/config/config_new.yaml
cd ${WORKSPACE}/TestCase
pytest test_*.py -v -n 4 --reruns=1 --reruns-delay=10 --alluredir ../result || exit 0
'''
}
catch (Exception err) {
echo 'test failed'
}
}
}
}
}
}
post {
always {
container('python') {
sh '''
cd ${WORKSPACE}
cp environment.properties result
'''
sh 'chmod -R o+xw result'
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'result']]
])
}
}
}
}
}