-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJenkinsfile
More file actions
60 lines (58 loc) · 2.13 KB
/
Jenkinsfile
File metadata and controls
60 lines (58 loc) · 2.13 KB
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
// First job
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
sh '''
pip install -r requirements.txt
'''
}
}
stage('Start API') {
steps {
echo 'Building..'
sh '''
FASTAPI_ENV=test python3 -m coverage run -m uvicorn src.main:app &
'''
}
}
stage('Scan') {
steps {
script {
try {
echo 'Scanning..'
sh '''
curl -Lo mapi ${MAYHEM_URL}/cli/mapi/linux-musl/latest/mapi && chmod +x mapi
'''
withCredentials([string(credentialsId: 'MAPI_TOKEN', variable: 'MAPI_TOKEN')]) {
sh '''
./mapi login ${MAPI_TOKEN}
./mapi run forallsecure-demo/mapi-action-examples/fastapi auto "http://localhost:8000/openapi.json" --url "http://localhost:8000/" --junit junit.xml --sarif mapi.sarif --html mapi.html
'''
}
} finally {
/* Kill python if it's still running, ignoring any errors */
sh 'pgrep python3 | xargs kill || true'
/* Generate coverage report */
sh 'python3 -m coverage xml -o coverage.xml'
}
}
}
}
}
post {
always {
echo 'Archive and Code coverage....'
archiveArtifacts artifacts: 'junit.xml, mapi.sarif, mapi.html, coverage.xml',
allowEmptyArchive: true,
fingerprint: true,
onlyIfSuccessful: false
junit 'junit.xml'
recordIssues(enabledForFailure: true,
tool: sarif(pattern: 'mapi.sarif'))
cobertura coberturaReportFile: 'coverage.xml', onlyStable: 'false'
}
}
}