-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
109 lines (105 loc) · 3.79 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!groovy
pipeline{
agent {
docker {
image 'python:3.7.4'
args '-u root'
}
}
environment {
CODACY_PROJECT_TOKEN = credentials('codacy-hamb')
}
triggers {
pollSCM 'H/10 * * * *'
}
options {
skipDefaultCheckout false
buildDiscarder(logRotator(numToKeepStr: '20'))
}
stages{
stage('Coverage to Codacy'){
steps {
slackSend (color: 'good', message: "hamb_pypi_pipeline_${GIT_BRANCH} - Starting build #${BUILD_NUMBER}. (<${env.BUILD_URL}|Open>)")
echo "coverage"
// Install pyodbc library dependencies
sh 'apt-get update && apt-get -y install g++ unixodbc-dev'
sh "pip install -r requirements-dev.txt"
sh "pip install coverage codacy-coverage"
sh "coverage run -m unittest discover tests -v"
sh "coverage xml -i"
sh "python-codacy-coverage -r coverage.xml"
}
// post {
// always {
// step([$class: 'CoberturaPublisher',
// autoUpdateHealth: false,
// autoUpdateStability: false,
// coberturaReportFile: 'coverage.xml',
// failNoReports: false,
// failUnhealthy: false,
// failUnstable: false,
// maxNumberOfBuilds: 10,
// onlyStable: false,
// sourceEncoding: 'ASCII',
// zoomCoverageChart: false])
// }
// }
}
stage('Deploy to Test Pypi Env') {
when {
anyOf {
branch 'qa';
}
}
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'e9f73e25-ab88-4382-9018-dd0841cc327c',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD'
]]) {
sh "pip install twine"
sh "rm -rf dist"
sh "python setup.py sdist"
sh "twine upload --repository-url https://test.pypi.org/legacy/ --skip-existing dist/* -u ${USERNAME} -p ${PASSWORD}"
}
}
}
stage('Deploy to Pypi') {
when {
branch 'master'
}
steps {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'e9f73e25-ab88-4382-9018-dd0841cc327c',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD'
]]) {
sh "pip install twine"
sh "rm -rf dist"
sh "python setup.py sdist"
sh "twine upload --skip-existing dist/* -u ${USERNAME} -p ${PASSWORD}"
}
}
}
}
post {
failure {
echo "fail"
slackSend (color: 'danger', message: "@here hamb_pypi_pipeline_${GIT_BRANCH} - Build #${BUILD_NUMBER} Failed. (<${env.BUILD_URL}|Open>)")
}
success {
echo "good"
slackSend (color: 'good', message: "hamb_pypi_pipeline_${GIT_BRANCH} - Build #${BUILD_NUMBER} Success. (<${env.BUILD_URL}|Open>)")
}
always {
echo 'Updating folder permissions.'
sh "chmod -R 777 ."
}
cleanup {
echo 'Workspace cleanup.'
deleteDir()
}
}
}