From 5045f95fc223b5463c0aaf3a857b68afcd75f647 Mon Sep 17 00:00:00 2001 From: "shikhar.s" Date: Fri, 5 Jul 2019 21:14:04 +0530 Subject: [PATCH] changes in file13 --- Jenkinsfile | 143 ++++++++++++++++++++++++++++---------------- Jenkinsfile2 | 166 --------------------------------------------------- 2 files changed, 93 insertions(+), 216 deletions(-) delete mode 100644 Jenkinsfile2 diff --git a/Jenkinsfile b/Jenkinsfile index 8690b6ad..d99b3f09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,8 @@ +#!/usr/bin/env groovy + +/** + * Jenkinsfile + */ pipeline { agent any options { @@ -38,57 +43,98 @@ pipeline { } } - - // 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 - // ]) - // } - // } - - stage('Test environment') { + stage ('Check_style') { 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 /home/cis/.local/bin/nosetests --with-xunit tests - ''' + 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('Test Run') { + stage ('Unit Tests') { steps { - sh '''python src/bitmessagemain.py -t''' + 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' + ] + } } } @@ -99,7 +145,6 @@ pipeline { } } - post { failure { mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build error " + @@ -118,6 +163,4 @@ pipeline { to: env.emailTo } } - - -} +} \ No newline at end of file diff --git a/Jenkinsfile2 b/Jenkinsfile2 deleted file mode 100644 index d99b3f09..00000000 --- a/Jenkinsfile2 +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env groovy - -/** - * Jenkinsfile - */ -pipeline { - agent any - 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 ('Checkout') { - steps { - checkout scm - } - } - */ - - stage ('Install_Requirements') { - 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} - pip install --upgrade pip - pip install -r requirements.txt -r dev-requirements.txt - make clean - """ - } - } - - stage ('Check_style') { - steps { - 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 { - 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