2020-01-10 12:02:45 +00:00
|
|
|
#!groovy
|
|
|
|
|
|
|
|
def prepareDocker () {
|
|
|
|
def img
|
|
|
|
stage('Prepare environment') {
|
2020-11-26 22:57:15 +00:00
|
|
|
dir('.imagebuild') {
|
|
|
|
def uid = sh returnStdout: true, script: 'id -u'
|
|
|
|
writeFile file: 'Dockerfile', text: """
|
|
|
|
FROM python:3.8-buster
|
|
|
|
RUN pip install pytest-cov PySocks && \\
|
|
|
|
useradd -m -u ${uid.trim()} jenkins
|
|
|
|
"""
|
|
|
|
img = docker.build('local:test-all-comics')
|
|
|
|
}
|
2020-01-10 12:02:45 +00:00
|
|
|
}
|
|
|
|
return img
|
|
|
|
}
|
|
|
|
|
|
|
|
def runTests() {
|
|
|
|
stage ('Install lib') {
|
2020-09-27 16:49:46 +00:00
|
|
|
sh "pip install --user -e .[css,dev]"
|
2020-01-10 12:02:45 +00:00
|
|
|
}
|
|
|
|
stage ('Run tests') {
|
2020-09-28 23:50:02 +00:00
|
|
|
withCredentials([string(credentialsId: 'proxymap', variable: 'PROXYMAP')]) {
|
2020-11-23 00:18:17 +00:00
|
|
|
sh '''
|
|
|
|
TESTALL=1 py.test -v --cov=dosagelib --cov-report xml \
|
|
|
|
--alluredir=allure-data \
|
|
|
|
--tb=short -n10 --junitxml=junit.xml \
|
|
|
|
tests/modules/check_comics.py || true
|
|
|
|
'''
|
2020-09-28 23:50:02 +00:00
|
|
|
}
|
2020-01-10 12:02:45 +00:00
|
|
|
}
|
|
|
|
stage('Report') {
|
|
|
|
junit 'junit.xml'
|
|
|
|
publishCoverage calculateDiffForChangeRequests: true,
|
|
|
|
sourceFileResolver: sourceFiles('STORE_LAST_BUILD'),
|
|
|
|
adapters: [
|
|
|
|
coberturaAdapter('coverage.xml')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ansiColor('xterm') {
|
|
|
|
node {
|
|
|
|
def img = prepareDocker()
|
|
|
|
|
2020-11-26 22:56:02 +00:00
|
|
|
stage('Checkout') {
|
|
|
|
checkout scm
|
|
|
|
}
|
|
|
|
|
2020-01-10 12:02:45 +00:00
|
|
|
img.inside {
|
|
|
|
runTests()
|
|
|
|
}
|
2020-11-23 00:18:17 +00:00
|
|
|
|
|
|
|
stage('Allure Report') {
|
2020-11-27 23:37:05 +00:00
|
|
|
copyArtifacts filter: 'allure-history.zip', optional: true, projectName: JOB_NAME
|
|
|
|
if (fileExists('allure-history.zip')) {
|
|
|
|
unzip dir: 'allure-data', quiet: true, zipFile: 'allure-history.zip'
|
|
|
|
sh 'rm -f allure-history.zip'
|
|
|
|
}
|
2020-11-23 08:42:58 +00:00
|
|
|
sh 'docker run --rm -v $PWD:/work -u $(id -u) tobix/allure-cli generate allure-data'
|
2020-11-27 23:37:05 +00:00
|
|
|
zip archive: true, dir: 'allure-report', glob: 'history/**', zipFile: 'allure-history.zip'
|
2020-11-23 00:18:17 +00:00
|
|
|
publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report'
|
|
|
|
}
|
2020-01-10 12:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|