2019-07-04 16:10:30 +02:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Jenkinsfile
|
|
|
|
*/
|
2019-07-03 15:45:01 +02:00
|
|
|
pipeline {
|
2019-07-03 15:52:03 +02:00
|
|
|
agent any
|
2019-07-04 16:10:30 +02:00
|
|
|
options {
|
|
|
|
buildDiscarder(
|
|
|
|
// Only keep the 10 most recent builds
|
|
|
|
logRotator(numToKeepStr:'10'))
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
projectName = 'BitMessage'
|
|
|
|
emailTo = 'kuldeep.m@cisinlabs.com'
|
|
|
|
emailFrom = 'kuldeep.m@cisinlabs.com'
|
|
|
|
VIRTUAL_ENV = "${env.WORKSPACE}/venv"
|
2019-07-03 15:45:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2019-07-04 16:10:30 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
stage ('Checkout') {
|
|
|
|
steps {
|
|
|
|
checkout scm
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
stage ('Install_Requirements') {
|
|
|
|
steps {
|
|
|
|
sh """
|
2019-07-05 12:32:05 +02:00
|
|
|
echo ${SHELL}
|
2019-07-04 16:10:30 +02:00
|
|
|
[ -d venv ] && rm -rf venv
|
|
|
|
#virtualenv --python=python2.7 venv
|
|
|
|
virtualenv venv
|
|
|
|
#. venv/bin/activate
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
2019-07-04 17:53:25 +02:00
|
|
|
pip install --upgrade pip
|
2019-07-04 16:10:30 +02:00
|
|
|
pip install -r requirements.txt -r dev-requirements.txt
|
2019-07-05 10:04:45 +02:00
|
|
|
make clean
|
2019-07-04 16:10:30 +02:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Check_style') {
|
|
|
|
steps {
|
2019-07-05 12:32:05 +02:00
|
|
|
// sh """
|
|
|
|
// #. venv/bin/activate
|
|
|
|
// [ -d report ] || mkdir report
|
|
|
|
// export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
// make check || true
|
|
|
|
// """
|
2019-07-04 16:10:30 +02:00
|
|
|
sh """
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
make flake8 | tee report/flake8.log || true
|
|
|
|
"""
|
|
|
|
sh """
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
make pylint | tee report/pylint.log || true
|
|
|
|
"""
|
|
|
|
step([$class: 'WarningsPublisher',
|
|
|
|
parserConfigurations: [[
|
|
|
|
parserName: 'Pep8',
|
|
|
|
pattern: 'report/flake8.log'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
parserName: 'pylint',
|
|
|
|
pattern: 'report/pylint.log'
|
|
|
|
]],
|
|
|
|
unstableTotalAll: '0',
|
|
|
|
usePreviousBuildAsReference: true
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Unit Tests') {
|
2019-07-03 15:45:01 +02:00
|
|
|
steps {
|
2019-07-04 16:10:30 +02:00
|
|
|
sh """
|
|
|
|
#. venv/bin/activate
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
make unittest || true
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
junit keepLongStdio: true, testResults: 'report/nosetests.xml'
|
|
|
|
publishHTML target: [
|
|
|
|
reportDir: 'report/coverage',
|
|
|
|
reportFiles: 'index.html',
|
|
|
|
reportName: 'Coverage Report - Unit Test'
|
|
|
|
]
|
|
|
|
}
|
2019-07-03 15:45:01 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-04 16:10:30 +02:00
|
|
|
|
|
|
|
stage ('System Tests') {
|
2019-07-03 15:45:01 +02:00
|
|
|
steps {
|
2019-07-04 16:10:30 +02:00
|
|
|
sh """
|
|
|
|
#. venv/bin/activate
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
// Write file containing test node connection information if needed.
|
|
|
|
// writeFile file: "test/fixtures/nodes.yaml", text: "---\n- node: <some-ip>\n"
|
|
|
|
make systest || true
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
junit keepLongStdio: true, testResults: 'report/nosetests.xml'
|
|
|
|
publishHTML target: [
|
|
|
|
reportDir: 'report/coverage',
|
|
|
|
reportFiles: 'index.html',
|
|
|
|
reportName: 'Coverage Report - System Test'
|
|
|
|
]
|
|
|
|
}
|
2019-07-03 15:45:01 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-04 16:10:30 +02:00
|
|
|
|
|
|
|
stage ('Docs') {
|
2019-07-03 15:45:01 +02:00
|
|
|
steps {
|
2019-07-04 16:10:30 +02:00
|
|
|
sh """
|
|
|
|
#. venv/bin/activate
|
|
|
|
export PATH=${VIRTUAL_ENV}/bin:${PATH}
|
|
|
|
PYTHONPATH=. pdoc --html --html-dir docs --overwrite env.projectName
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
publishHTML target: [
|
|
|
|
reportDir: 'docs/*',
|
|
|
|
reportFiles: 'index.html',
|
|
|
|
reportName: 'Module Documentation'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Cleanup') {
|
|
|
|
steps {
|
|
|
|
sh 'rm -rf venv'
|
2019-07-03 15:45:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 16:10:30 +02:00
|
|
|
|
2019-07-03 15:45:01 +02:00
|
|
|
post {
|
|
|
|
failure {
|
2019-07-04 16:10:30 +02:00
|
|
|
mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build error " +
|
|
|
|
"is here: ${env.BUILD_URL}\nStarted by ${env.BUILD_CAUSE}" ,
|
|
|
|
from: env.emailFrom,
|
|
|
|
//replyTo: env.emailFrom,
|
|
|
|
subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build failed",
|
|
|
|
to: env.emailTo
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build successful\n" +
|
|
|
|
"Started by ${env.BUILD_CAUSE}",
|
|
|
|
from: env.emailFrom,
|
|
|
|
//replyTo: env.emailFrom,
|
|
|
|
subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build successful",
|
|
|
|
to: env.emailTo
|
2019-07-03 15:45:01 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-04 16:10:30 +02:00
|
|
|
}
|