-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
59 lines (59 loc) · 1.99 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
pipeline {
agent any
environment {
PROJECT="pygrafana"
SONARQUBE="false"
VERACODE="false"
}
stages {
stage('Build') {
steps {
sh 'virtualenv venv ; . venv/bin/activate ; pip install -r requirements.txt ; python setup.py install'
sh 'python setup.py sdist --formats=gztar,zip'
}
}
stage('Test') {
steps {
sh '. venv/bin/activate ; python tests/test_api.py'
}
}
stage('Code Analysis') {
steps {
parallel(
"SonarQube Analysis": {
script {
if (SONARQUBE == "true") {
scannerHome = tool 'sonarqube-scanner';
withSonarQubeEnv('sonarqube-server') {
sh "cp /tmp/${PROJECT}-sonar-scanner.properties /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube-scanner/conf/sonar-scanner.properties ; ${scannerHome}/bin/sonar-scanner"
}
}
}
},
"Veracode Analysis": {
script {
if (VERACODE == "true") {
withCredentials([usernamePassword(credentialsId: 'VeracodeAPI', passwordVariable: 'veracode_password', usernameVariable: 'veracode_username')]) {
veracode applicationName: 'python-app',
debug: true,
timeout: 480,
criticality: 'Medium',
scanName: '$timestamp python-app #$buildnumber',
createProfile: true,
uploadIncludesPattern: 'dist/**.zip',
vpassword: "${env.veracode_password}",
vuser: "${env.veracode_username}"
}
}
}
}
)
}
}
stage('Nexus Upload') {
steps {
sh '. venv/bin/activate ; vers=$(pip freeze | grep "${PROJECT}" | sed -n \"s/${PROJECT}==//p\") ; package=$(echo "dist/${PROJECT}-$vers.tar.gz") ; twine upload $package ; rm -rf dist/*'
}
}
}
}