-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
78 lines (78 loc) · 2.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
pipeline {
agent { docker { image 'python:3' } }
stages {
stage('setup') {
steps {
sh """#!/bin/bash
python3 -m venv venv
source venv/bin/activate
pip install --no-cache --upgrade pip wheel setuptools twine
pip install --no-cache -e .
"""
}
}
stage('coverage') {
steps {
sh """#!/bin/bash
source venv/bin/activate
python -m pip install --no-cache --upgrade coverage pytest
python -m coverage run --branch --source pynamelix -m pytest --disable-pytest-warnings --junitxml junittest-coverage.xml
python -m coverage xml
"""
}
}
stage('pylint') {
steps {
sh """#!/bin/bash
source venv/bin/activate
python -m pip install --no-cache --upgrade pylint pylint_junit
python -m pylint --rcfile=setup.cfg --output-format=pylint_junit.JUnitReporter pynamelix | tee junittest-pylint.xml
"""
}
}
stage('build') {
steps {
sh """#!/bin/bash
source venv/bin/activate
python setup.py sdist bdist_wheel
"""
}
}
stage('publish') {
when {
branch 'master'
}
steps {
script {
PYPI_VERSION = sh (
script: """#!/bin/bash
source venv/bin/activate
python setup.py --version
""",
returnStdout: true
).trim()
echo "PyPi version: ${PYPI_VERSION}"
if (PYPI_VERSION.length() < 8){
echo "Publish on PyPi"
sh """#!/bin/bash
source venv/bin/activate
python -m twine upload dist/*
"""
}
else{
echo "Skip upload to PyPi"
}
}
}
}
}
post {
always {
junit allowEmptyResults: true, healthScaleFactor: 0.0, testResults: 'junittest*.xml'
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
cleanup {
cleanWs()
}
}
}