forked from anieto-unir/helloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-P22-T6
85 lines (78 loc) · 2.76 KB
/
Jenkinsfile-P22-T6
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
pipeline
{
agent any
stages
{
stage('Get Code')
{
steps{
bat 'echo "Hello World!"'
git 'https://github.com/anieto-unir/helloworld.git'
bat 'dir'
bat 'echo %WORKSPACE%'
}
}
stage('Unit Test')
{
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
bat '''
SET PYTHONPATH=%WORKSPACE%
coverage run --branch --source=app --omit=app\\__init__.py,app\\api.py -m pytest --junitxml=result-unit.xml test\\unit
'''
junit 'result*.xml'
}
}
}
stage('Coverage')
{
steps
{
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
bat '''
coverage xml
'''
cobertura coberturaReportFile: 'coverage.xml', failUnhealthy: true, failUnstable: false, conditionalCoverageTargets: '95,80,90'
script
{
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
if (currentBuild.result == 'UNSTABLE')
error("")
}
}
}
}
}
stage('Static')
{
steps
{
bat 'flake8 --exit-zero --format=pylint app >flake8.out'
script
{
def flake8 = scanForIssues tool: flake8(pattern: 'flake8.out')
publishIssues issues: [flake8], qualityGates: [[threshold: 10, type: 'TOTAL', unstable: false],[threshold: 5, type: 'TOTAL', unstable: true]]
}
}
}
stage('Security')
{
steps
{
bat 'bandit --exit-zero -r . -f custom -o bandit.out --severity-level medium --msg-template "{abspath}:{line}: [{test_id}] {msg}"'
recordIssues tools: [pyLint(name: 'Bandit', pattern: 'bandit.out')], qualityGates: [[threshold: 3, type: 'TOTAL', unstable: true], [threshold: 4, type: 'TOTAL', unstable: false]]
}
}
stage('Performance')
{
steps {
bat '''
SET FLASK_APP=app\\api.py
start flask run >NUL 2>&1
C:\\Unir\\Ejercicios\\apache-jmeter-5.4.3\\bin\\jmeter -n -t test\\jmeter\\flask.jmx -f -l flask.jtl
'''
perfReport sourceDataFiles: 'flask.jtl'
}
}
}
}