diff --git a/Jenkinsfile b/Jenkinsfile index 345231f6..dd7a6580 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,37 +1,166 @@ +#!/usr/bin/env groovy + +/** + * Jenkinsfile + */ pipeline { agent any - - triggers { - pollSCM('*/5 * * * *') + 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" } - stages { - stage('Build environment') { + + /* + stage ('Checkout') { steps { - sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate''' - sh '''pip install -r /home/cis/Desktop/Python/PyBitmessage/requirements.txt''' + checkout scm } } - stage('Test environment') { + */ + + stage ('Install_Requirements') { steps { - sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate - cd /home/cis/Desktop/Python/PyBitmessage - sudo python setup.py install - sudo /home/cis/.local/bin/nosetests --with-xunit tests - ''' + sh """ + echo ${SHELL} + [ -d venv ] && rm -rf venv + #virtualenv --python=python2.7 venv + virtualenv venv + #. venv/bin/activate + export PATH=${VIRTUAL_ENV}/bin:${PATH} + pip install --upgrade pip + pip install -r requirements.txt -r dev-requirements.txt + make clean + """ } } - stage('Test Run') { + + stage ('Check_style') { steps { - sh '''python /home/cis/Desktop/Python/PyBitmessage/src/bitmessagemain.py -t - ''' + sh """ + #. venv/bin/activate + [ -d report ] || mkdir report + export PATH=${VIRTUAL_ENV}/bin:${PATH} + make check || true + """ + 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') { + steps { + 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' + ] + } + } + } + + stage ('System Tests') { + steps { + 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: \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' + ] + } + } + } + + stage ('Docs') { + steps { + 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' } } } + post { failure { - echo "Send e-mail, when failed" + 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 } } -} +} \ No newline at end of file diff --git a/Jenkinsfile1 b/Jenkinsfile1 new file mode 100644 index 00000000..345231f6 --- /dev/null +++ b/Jenkinsfile1 @@ -0,0 +1,37 @@ +pipeline { + agent any + + triggers { + pollSCM('*/5 * * * *') + } + + + stages { + stage('Build environment') { + steps { + sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate''' + sh '''pip install -r /home/cis/Desktop/Python/PyBitmessage/requirements.txt''' + } + } + stage('Test environment') { + steps { + sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate + cd /home/cis/Desktop/Python/PyBitmessage + sudo python setup.py install + sudo /home/cis/.local/bin/nosetests --with-xunit tests + ''' + } + } + stage('Test Run') { + steps { + sh '''python /home/cis/Desktop/Python/PyBitmessage/src/bitmessagemain.py -t + ''' + } + } + } + post { + failure { + echo "Send e-mail, when failed" + } + } +}