PyBitmessage-2021-04-27/Jenkinsfile

300 lines
10 KiB
Plaintext
Raw Normal View History

2019-07-03 15:45:01 +02:00
pipeline {
2019-07-03 15:52:03 +02:00
agent any
2019-07-30 11:17:16 +02:00
triggers {
pollSCM('*/5 * * * 1-5')
}
2019-07-05 16:35:31 +02:00
options {
2019-08-12 17:51:03 +02:00
// skipDefaultCheckout(true)
2019-07-30 11:17:16 +02:00
// Keep the 10 most recent builds
buildDiscarder(logRotator(numToKeepStr: '10'))
2019-08-12 17:51:03 +02:00
// timestamps()
2019-07-05 16:35:31 +02:00
}
environment {
projectName = 'BitMessage'
emailTo = 'kuldeep.m@cisinlabs.com'
2019-07-06 14:41:35 +02:00
emailFrom = 'cis.dev393@gmail.com'
2019-07-05 16:35:31 +02:00
VIRTUAL_ENV = "${env.WORKSPACE}/venv"
}
2019-07-03 15:45:01 +02:00
stages {
2019-07-04 16:10:30 +02:00
2019-07-30 11:17:16 +02:00
2019-08-12 17:51:03 +02:00
// stage ('Checkout') {
// steps {
// checkout scm
// }
// }
2019-07-30 11:17:16 +02:00
2019-07-04 16:10:30 +02:00
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
2019-07-06 15:45:06 +02:00
#. venv/bin/activate
2019-07-04 16:10:30 +02:00
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
"""
}
}
2019-07-05 17:33:39 +02:00
2019-08-13 12:28:05 +02:00
// stage ('Check_style') {
// steps {
// sh """
// if [ ! -d venv ] ; then
// virtualenv --python=python2.7 venv
// fi
// source venv/bin/activate
// export PYTHONPATH="$PWD:$PYTHONPATH"
// pip install pylint
// cd repo
// ### Need this because some strange control sequences when using default TERM=xterm
// export TERM="linux"
// ## || exit 0 because pylint only exits with 0 if everything is correct
// pylint --rcfile=pylint.cfg $(find . -maxdepth 1 -name "*.py" -print) MYMODULE/ > pylint.log || exit 0
// """
// step([$class: 'WarningsPublisher',
// parserConfigurations: [
// [
// parserName: 'pylint',
// pattern: 'report/pylint.log'
// ]],
// unstableTotalAll: '0',
// usePreviousBuildAsReference: true
// ])
// }
// }
2019-07-05 15:56:52 +02:00
stage('changes in script check') {
steps {
sh '''
echo ${SHELL}
'''
// sudo /home/cis/.local/bin/nosetests --with-xunit tests
}
}
2019-07-05 18:00:57 +02:00
stage('Test environment') {
2019-07-04 16:10:30 +02:00
steps {
2019-07-05 18:00:57 +02:00
sh '''
echo ${SHELL}
[ -d venv ] && rm -rf venv
#virtualenv --python=python2.7 venv
virtualenv venv
2019-07-06 15:45:06 +02:00
#. venv/bin/activate
2019-07-05 18:00:57 +02:00
export PATH=${VIRTUAL_ENV}/bin:${PATH}
python setup.py install
pip install pylint
2019-08-27 19:14:55 +02:00
pip install radon
2019-08-28 16:09:32 +02:00
pip install coverage
2019-07-05 18:00:57 +02:00
'''
2019-08-17 08:53:58 +02:00
// sudo /home/cis/.local/bin/nosetests --with-xunit tests
2019-07-05 17:44:04 +02:00
}
2019-07-05 18:00:57 +02:00
}
2019-07-05 17:44:04 +02:00
2019-08-17 15:49:43 +02:00
stage('Pylint Checker'){
steps{
sh '''
export TERM="linux"
pylint --rcfile=pylint.cfg $(find . -maxdepth 1 -name "*.py" -print) PyBitmessage/ > pylint.log || exit 0
2019-08-17 15:49:43 +02:00
'''
}
}
2019-09-24 12:35:01 +02:00
// stage('Nosetest'){
// steps{
// sh '''
// echo ${SHELL}
// [ -d venv ] && rm -rf venv
// #virtualenv --python=python2.7 venv
// virtualenv venv
// #. venv/bin/activate
// export PATH=${VIRTUAL_ENV}/bin:${PATH}
// python setup.py install
// sudo apt-get install python-mock python-nose python-coverage pylint
// '''
// }
// }
2019-08-13 12:28:05 +02:00
// stage('Pylint Checker') {
// steps {
// sh '''
// echo ${SHELL}
// [ -d venv ] && rm -rf venv
// #virtualenv --python=python2.7 venv
// virtualenv venv
// #. venv/bin/activate
// export PATH=${VIRTUAL_ENV}/bin:${PATH}
2019-07-06 14:41:35 +02:00
2019-08-13 12:28:05 +02:00
// pip install pylint
2019-07-06 14:41:35 +02:00
2019-07-06 15:45:06 +02:00
2019-08-13 12:28:05 +02:00
// export TERM="linux"
2019-07-06 14:41:35 +02:00
2019-08-13 12:28:05 +02:00
// ## || exit 0 because pylint only exits with 0 if everything is correct
// pylint --rcfile=pylint.cfg $(find . -maxdepth 1 -name "*.py" -print) Pybitmessage/ > pylint.log || exit 0
// '''
// }
// }
2019-07-06 14:41:35 +02:00
2019-08-27 18:49:31 +02:00
stage('Static code metrics') {
2019-08-26 16:24:40 +02:00
steps {
2019-08-28 17:39:39 +02:00
echo "Raw metrics"
sh ''' echo ${SHELL}
[ -d venv ] && rm -rf venv
#virtualenv --python=python2.7 venv
virtualenv venv
#. venv/bin/activate
export PATH=${VIRTUAL_ENV}/bin:${PATH}
python setup.py install
pip install radon
radon raw --json PyBitmessage/ > raw_report.json
radon cc --json PyBitmessage/ > cc_report.json
2019-09-24 12:35:01 +02:00
radon mi --json PyBitmessage/ > mi_report.json
2019-08-28 17:39:39 +02:00
'''
2019-08-28 15:07:05 +02:00
echo "Test coverage"
2019-08-28 16:38:59 +02:00
sh '''
echo ${SHELL}
[ -d venv ] && rm -rf venv
#virtualenv --python=python2.7 venv
virtualenv venv
#. venv/bin/activate
export PATH=${VIRTUAL_ENV}/bin:${PATH}
python setup.py install
pip install coverage
2019-08-28 16:34:04 +02:00
coverage run src/bitmessagemain.py -t 1 1 2 3
2019-08-28 16:04:53 +02:00
python -m coverage xml -o PyBitmessage/coverage.xml
2019-08-28 15:07:05 +02:00
'''
2019-08-28 16:53:20 +02:00
2019-08-28 17:25:28 +02:00
echo "Style check"
sh ''' echo ${SHELL}
[ -d venv ] && rm -rf venv
#virtualenv --python=python2.7 venv
virtualenv venv
#. venv/bin/activate
export PATH=${VIRTUAL_ENV}/bin:${PATH}
python setup.py install
pip install pylint
pylint PyBitmessage || true
'''
2019-08-28 15:07:05 +02:00
}
post{
always{
step([$class: 'CoberturaPublisher',
autoUpdateHealth: false,
autoUpdateStability: false,
2019-08-28 16:04:53 +02:00
coberturaReportFile: 'PyBitmessage/coverage.xml',
2019-08-28 15:07:05 +02:00
failNoReports: false,
failUnhealthy: false,
failUnstable: false,
maxNumberOfBuilds: 10,
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: false])
}
}
}
2019-08-30 15:32:29 +02:00
stage('Unit tests') {
steps {
sh ''' export PATH=${VIRTUAL_ENV}/bin:${PATH}
pip install pytest
pip install psutil
pip install python-prctl==1.5.0
2019-09-24 12:35:01 +02:00
python -m pytest --verbose --junit-xml results.xml
'''
}
post {
always {
// Archive unit tests for the future
junit allowEmptyResults: true, testResults: 'results.xml'
}
}
}
stage('Setup Test') {
steps {
sh ''' export PATH=${VIRTUAL_ENV}/bin:${PATH}
pip install pytest
pip install psutil
pip install python-prctl==1.5.0
2019-08-30 15:32:29 +02:00
python -m pytest --verbose --junit-xml results.xml
'''
}
post {
always {
// Archive unit tests for the future
junit allowEmptyResults: true, testResults: 'results.xml'
}
}
}
2019-08-28 15:54:08 +02:00
// stage('Unit tests') {
// steps {
// sh ''' source activate ${BUILD_TAG}
// python -m pytest --verbose --junit-xml reports/unit_tests.xml
// '''
// }
// post {
// always {
// // Archive unit tests for the future
// junit (allowEmptyResults: true,
// testResults: './reports/unit_tests.xml',
// testResults: true)
// }
// }
// }
2019-08-26 16:24:40 +02:00
2019-07-05 18:00:57 +02:00
stage('Test Run') {
steps {
sh '''python src/bitmessagemain.py -t'''
2019-07-05 17:33:39 +02:00
}
}
stage ('Cleanup') {
steps {
sh 'rm -rf venv'
2019-07-03 15:45:01 +02:00
}
}
}
2019-07-05 15:56:52 +02:00
2019-07-05 18:00:57 +02:00
2019-07-05 16:54:52 +02:00
post {
failure {
2019-07-05 17:33:39 +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-05 16:54:52 +02:00
}
2019-08-27 18:49:31 +02:00
2019-07-05 16:51:38 +02:00
}
2019-07-05 18:00:57 +02:00
}