diff --git a/Jenkinsfile b/Jenkinsfile index 7ab5f50e1..188dd09e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,88 +1,124 @@ -pipeline { - agent none - environment { - ON_JENKINS = 'TRUE' - } - stages { - stage ('Lisk Provisioning') { - steps { - node('master-nano-01'){ - lock(resource: "master-nano-01", inversePrecedence: true) { - deleteDir() - checkout scm - sh '''#!/bin/bash - env - # Clean up old processes - pkill -f selenium -9 || true - pkill -f Xvfb -9 || true - rm -rf /tmp/.X0-lock || true - pkill -f app.js || true - pkill -f webpack-dev-server -9 || true +environment { + ON_JENKINS = 'TRUE' +} +node('lisk-nano-01'){ + lock(resource: "master-nano-01", inversePrecedence: true) { + stage ('Cleanup Orphaned Processes') { + try { + sh ''' + # Clean up old processes + cd ~/lisk-test-nano + bash lisk.sh stop_node + pkill -f selenium -9 || true + pkill -f Xvfb -9 || true + rm -rf /tmp/.X0-lock || true + pkill -f webpack -9 || true + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, installation failed') + } + } + + stage ('Prepare Workspace') { + try { + deleteDir() + checkout scm + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Checkout failed') + } + } + + stage ('Start Lisk Core') { + try { + sh '''#!/bin/bash + cd ~/lisk-test-nano + bash lisk.sh rebuild -0 + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Lisk Core failed to start') + } + } - # Start lisk and make sure its current - cd /var/lib/jenkins/workspace/ - git clone https://github.com/LiskHQ/lisk.git - cd /var/lib/jenkins/workspace/lisk - git checkout development - git pull - dropdb lisk_test || true - createdb lisk_test - psql -d lisk_test -c "alter user "$USER" with password 'password';" - cp /var/lib/jenkins/workspace/lisk-node-Linux-x86_64.tar.gz . - tar -zxvf lisk-node-Linux-x86_64.tar.gz - npm install - git submodule init - git submodule update - cd public - npm install - bower install - grunt release - cd .. - cd test/lisk-js/; npm install; cd ../.. - cp test/config.json test/genesisBlock.json . - export NODE_ENV=test - BUILD_ID=dontKillMe ~/start_lisk.sh + stage ('Build Nano') { + try { + sh '''#!/bin/bash + # Install Electron + npm install - # Build nano - cd $WORKSPACE/src - npm install + # Build nano + cd $WORKSPACE/src + npm install - # Add coveralls config file - cp ~/.coveralls.yml-nano .coveralls.yml + # Add coveralls config file + cp ~/.coveralls.yml-nano .coveralls.yml - # Run Build - npm run build + # Run Build + npm run build + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Nano build failed') + } + } - # Run test - npm run test + stage ('Run Tests') { + try { + sh ''' + # Run test + cd $WORKSPACE/src + npm run test + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + error('Stopping build, Test suite failed') + } + } - # Run Dev build and Build - export NODE_ENV= - npm run dev &> .lisk-nano.log & - sleep 20 + stage ('Start Dev Server and Run Tests') { + try { + sh ''' + # Prepare lisk core for testing + bash ~/tx.sh + + # Run Dev build and Build + cd $WORKSPACE/src + export NODE_ENV= + npm run dev &> .lisk-nano.log & + sleep 30 - # End to End test configuration - export DISPLAY=:99 - Xvfb :99 -ac -screen 0 1024x768x24 & - ./node_modules/protractor/bin/webdriver-manager update - ./node_modules/protractor/bin/webdriver-manager start & + # End to End test configuration + export DISPLAY=:99 + Xvfb :99 -ac -screen 0 1280x1024x24 & + ./node_modules/protractor/bin/webdriver-manager update + ./node_modules/protractor/bin/webdriver-manager start & - # Prepare lisk core for testing - bash ~/tx.sh + # Run End to End Tests + npm run e2e-test - # Run End to End Tests - npm run e2e-test + cd ~/lisk-test-nano + bash lisk.sh stop_node + pkill -f selenium -9 || true + pkill -f Xvfb -9 || true + rm -rf /tmp/.X0-lock || true + pkill -f webpack -9 || true - pkill -f selenium -9 || true - pkill -f Xvfb -9 || true - rm -rf /tmp/.X0-lock || true - pkill -f app.js || true - pkill -f webpack-dev-server -9 || true - ''' - milestone 1 - } - } + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, End to End Test suite failed') } } + + stage ('Set milestone') { + milestone 1 + } } }