Jenkinsfile: return if error in script

pull/559/head
pabloFuente 2020-11-10 21:25:25 +01:00
parent 67ea4f0491
commit b7f492fead
2 changed files with 119 additions and 147 deletions

View File

@ -19,7 +19,7 @@
"ts-node": "9.0.0",
"tslint": "6.1.3",
"typedoc": "0.19.2",
"typescript": "3.8.3"
"typescript": "3.9.2"
},
"license": "Apache-2.0",
"main": "lib/index.js",

View File

@ -11,7 +11,7 @@ node('container') {
def mycontainer = docker.image('openvidu/openvidu-test-e2e:$DISTRO')
mycontainer.pull()
mycontainer.inside('--name e2e -p 4200:4200 -p 4443:4443 -p 5555:5555 -u root -e MY_UID=0 -v /var/run/docker.sock:/var/run/docker.sock:rw -v /dev/shm:/dev/shm -v /opt/openvidu:/opt/openvidu --privileged') {
try {
stage('Preparation') {
sh 'rm -rf ~/.m2 || true'
sh 'rm -rf openvidu || true'
@ -40,10 +40,7 @@ node('container') {
fi
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Browser build') {
sh(script: '''#!/bin/bash
cd openvidu
@ -57,10 +54,7 @@ node('container') {
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Node Client build') {
sh(script: '''#!/bin/bash
cd openvidu
@ -74,12 +68,10 @@ node('container') {
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu TestApp build') {
sh(script: '''#!/bin/bash
set -e
cd openvidu
if [[ $OPENVIDU_TESTAPP_COMMIT != "default" ]]; then
git checkout -f $OPENVIDU_TESTAPP_COMMIT
@ -93,10 +85,7 @@ node('container') {
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Java Client build') {
sh(script: '''#!/bin/bash
cd openvidu
@ -110,32 +99,20 @@ node('container') {
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu parent build') {
sh 'cd openvidu && mvn --batch-mode versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST'
sh 'cd openvidu && mvn --batch-mode -DskipTests=true clean install'
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Server unit tests') {
sh 'cd openvidu/openvidu-server && mvn --batch-mode -Dtest=io.openvidu.server.test.unit.*Test test'
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Server integration tests') {
sh 'cd openvidu/openvidu-server && mvn --batch-mode -Dtest=io.openvidu.server.test.integration.*Test test'
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage('OpenVidu Server build') {
sh(script: '''#!/bin/bash
cd openvidu/openvidu-server/src/dashboard && npm install --unsafe-perm && npm install /opt/openvidu/openvidu-browser-*.tgz && export NG_CLI_ANALYTICS="false" && npm run build-prod
@ -144,10 +121,7 @@ node('container') {
cp target/openvidu-server*.jar /opt/openvidu
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
try {
stage ('Environment Launch') {
sh 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/CN=www.mydom.com/O=My Company LTD./C=US" -keyout /opt/openvidu/testapp/key.pem -out /opt/openvidu/testapp/cert.pem'
sh 'cd /opt/openvidu/testapp && http-server -S -p 4200 &> /opt/openvidu/testapp.log &'
@ -164,9 +138,7 @@ node('container') {
'''.stripIndent())
sh 'until $(curl --insecure --output /dev/null --silent --head --fail https://OPENVIDUAPP:MY_SECRET@localhost:4443/); do echo "Waiting for openvidu-server..."; sleep 2; done'
}
} catch (error) {
currentBuild.result = 'FAILURE'
}
stage ('OpenVidu E2E tests') {
try {
sh(script: '''#!/bin/bash