Jenkinsfile updated with try-catchs

pull/559/head
pabloFuente 2020-11-10 20:51:33 +01:00
parent d4eac2c895
commit 339a894682
1 changed files with 146 additions and 106 deletions

View File

@ -11,121 +11,161 @@ node('container') {
def mycontainer = docker.image('openvidu/openvidu-test-e2e:$DISTRO') def mycontainer = docker.image('openvidu/openvidu-test-e2e:$DISTRO')
mycontainer.pull() 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') { 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') {
stage('Preparation') { try {
sh 'rm -rf ~/.m2 || true' stage('Preparation') {
sh 'rm -rf openvidu || true' sh 'rm -rf ~/.m2 || true'
sh 'rm -rf kurento-java || true' sh 'rm -rf openvidu || true'
sh 'git clone https://github.com/OpenVidu/openvidu.git' sh 'rm -rf kurento-java || true'
sh 'cd openvidu && git fetch --all && git checkout $OPENVIDU_COMMIT' sh 'git clone https://github.com/OpenVidu/openvidu.git'
sh(script: '''#!/bin/bash sh 'cd openvidu && git fetch --all && git checkout $OPENVIDU_COMMIT'
if $KURENTO_JAVA_SNAPSHOT ; then sh(script: '''#!/bin/bash
git clone https://github.com/Kurento/kurento-java.git if $KURENTO_JAVA_SNAPSHOT ; then
cd kurento-java && MVN_VERSION=$(mvn --batch-mode -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) git clone https://github.com/Kurento/kurento-java.git
cd ../openvidu && mvn --batch-mode versions:set-property -Dproperty=version.kurento -DnewVersion=$MVN_VERSION cd kurento-java && MVN_VERSION=$(mvn --batch-mode -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-client:$MVN_VERSION cd ../openvidu && mvn --batch-mode versions:set-property -Dproperty=version.kurento -DnewVersion=$MVN_VERSION
mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-jsonrpc-client-jetty:$MVN_VERSION mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-client:$MVN_VERSION
mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-jsonrpc-server:$MVN_VERSION mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-jsonrpc-client-jetty:$MVN_VERSION
mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-test:$MVN_VERSION mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-jsonrpc-server:$MVN_VERSION
fi mvn dependency:get -DrepoUrl=https://maven.openvidu.io/repository/snapshots/ -Dartifact=org.kurento:kurento-test:$MVN_VERSION
'''.stripIndent()) fi
sh(script: '''#!/bin/bash '''.stripIndent())
if $KURENTO_MEDIA_SERVER_DEV ; then sh(script: '''#!/bin/bash
echo "Upgrading KMS to dev version" if $KURENTO_MEDIA_SERVER_DEV ; then
sudo apt-get update && sudo apt-get install -y aptitude echo "Upgrading KMS to dev version"
sudo aptitude remove -y kurento-media-server sudo apt-get update && sudo apt-get install -y aptitude
DISTRO=`lsb_release --codename | cut -f2` sudo aptitude remove -y kurento-media-server
sudo echo "deb [arch=amd64] http://ubuntu.openvidu.io/dev $DISTRO kms6" | sudo tee /etc/apt/sources.list.d/kurento.list DISTRO=`lsb_release --codename | cut -f2`
sudo apt-get update && sudo apt-get --yes -o Dpkg::Options::="--force-confnew" install kurento-media-server sudo echo "deb [arch=amd64] http://ubuntu.openvidu.io/dev $DISTRO kms6" | sudo tee /etc/apt/sources.list.d/kurento.list
fi sudo apt-get update && sudo apt-get --yes -o Dpkg::Options::="--force-confnew" install kurento-media-server
'''.stripIndent()) fi
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage('OpenVidu Browser build') { try {
sh(script: '''#!/bin/bash stage('OpenVidu Browser build') {
cd openvidu sh(script: '''#!/bin/bash
if [[ $OPENVIDU_BROWSER_COMMIT != "default" ]]; then cd openvidu
git checkout -f $OPENVIDU_BROWSER_COMMIT if [[ $OPENVIDU_BROWSER_COMMIT != "default" ]]; then
fi git checkout -f $OPENVIDU_BROWSER_COMMIT
cd openvidu-browser fi
npm install --unsafe-perm && npm run build && npm pack cd openvidu-browser
cp openvidu-browser-*.tgz /opt/openvidu npm install --unsafe-perm && npm run build && npm pack
cd .. cp openvidu-browser-*.tgz /opt/openvidu
git checkout -f $OPENVIDU_COMMIT cd ..
'''.stripIndent()) git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage('OpenVidu Node Client build') { try {
sh(script: '''#!/bin/bash stage('OpenVidu Node Client build') {
cd openvidu sh(script: '''#!/bin/bash
if [[ $OPENVIDU_NODE_CLIENT_COMMIT != "default" ]]; then cd openvidu
git checkout -f $OPENVIDU_NODE_CLIENT_COMMIT if [[ $OPENVIDU_NODE_CLIENT_COMMIT != "default" ]]; then
fi git checkout -f $OPENVIDU_NODE_CLIENT_COMMIT
cd openvidu-node-client fi
npm install --unsafe-perm && npm run build && npm pack cd openvidu-node-client
cp openvidu-node-client-*.tgz /opt/openvidu npm install --unsafe-perm && npm run build && npm pack
cd .. cp openvidu-node-client-*.tgz /opt/openvidu
git checkout -f $OPENVIDU_COMMIT cd ..
'''.stripIndent()) git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage('OpenVidu TestApp build') { try {
sh(script: '''#!/bin/bash stage('OpenVidu TestApp build') {
cd openvidu sh(script: '''#!/bin/bash
if [[ $OPENVIDU_TESTAPP_COMMIT != "default" ]]; then cd openvidu
git checkout -f $OPENVIDU_TESTAPP_COMMIT if [[ $OPENVIDU_TESTAPP_COMMIT != "default" ]]; then
fi git checkout -f $OPENVIDU_TESTAPP_COMMIT
cd openvidu-testapp fi
npm install --unsafe-perm cd openvidu-testapp
npm install /opt/openvidu/openvidu-browser-*.tgz npm install --unsafe-perm
npm install /opt/openvidu/openvidu-node-client-*.tgz npm install /opt/openvidu/openvidu-browser-*.tgz
export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng build --prod --output-path=/opt/openvidu/testapp npm install /opt/openvidu/openvidu-node-client-*.tgz
cd .. export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng build --prod --output-path=/opt/openvidu/testapp
git checkout -f $OPENVIDU_COMMIT cd ..
'''.stripIndent()) git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage('OpenVidu Java Client build') { try {
sh(script: '''#!/bin/bash stage('OpenVidu Java Client build') {
cd openvidu sh(script: '''#!/bin/bash
if [[ $OPENVIDU_JAVA_CLIENT_COMMIT != "default" ]]; then cd openvidu
git checkout -f $OPENVIDU_JAVA_CLIENT_COMMIT if [[ $OPENVIDU_JAVA_CLIENT_COMMIT != "default" ]]; then
fi git checkout -f $OPENVIDU_JAVA_CLIENT_COMMIT
cd openvidu-java-client fi
mvn --batch-mode versions:set -DnewVersion=TEST cd openvidu-java-client
mvn clean compile package mvn --batch-mode versions:set -DnewVersion=TEST
mvn install:install-file -Dfile=target/openvidu-java-client-TEST.jar -DgroupId=io.openvidu -DartifactId=openvidu-java-client -Dversion=TEST -Dpackaging=jar mvn clean compile package
git checkout -f $OPENVIDU_COMMIT mvn install:install-file -Dfile=target/openvidu-java-client-TEST.jar -DgroupId=io.openvidu -DartifactId=openvidu-java-client -Dversion=TEST -Dpackaging=jar
'''.stripIndent()) git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage('OpenVidu parent build') { try {
sh 'cd openvidu && mvn --batch-mode versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST' stage('OpenVidu parent build') {
sh 'cd openvidu && mvn --batch-mode -DskipTests=true clean install' 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'
} }
stage('OpenVidu Server unit tests') { try {
sh 'cd openvidu/openvidu-server && mvn --batch-mode -Dtest=io.openvidu.server.test.unit.*Test test' 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'
} }
stage('OpenVidu Server integration tests') { try {
sh 'cd openvidu/openvidu-server && mvn --batch-mode -Dtest=io.openvidu.server.test.integration.*Test test' 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'
} }
stage('OpenVidu Server build') { try {
sh(script: '''#!/bin/bash stage('OpenVidu Server build') {
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 sh(script: '''#!/bin/bash
cd ../.. 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
mvn --batch-mode package cd ../..
cp target/openvidu-server*.jar /opt/openvidu mvn --batch-mode package
'''.stripIndent()) cp target/openvidu-server*.jar /opt/openvidu
'''.stripIndent())
}
} catch (error) {
currentBuild.result = 'FAILURE'
} }
stage ('Environment Launch') { try {
sh 'sudo 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' stage ('Environment Launch') {
sh 'cd /opt/openvidu/testapp && http-server -S -p 4200 &> /opt/openvidu/testapp.log &' 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 '/usr/bin/kurento-media-server &> /kms.log &' sh 'cd /opt/openvidu/testapp && http-server -S -p 4200 &> /opt/openvidu/testapp.log &'
sh 'until $(curl --insecure --output /dev/null --silent http://127.0.0.1:8888/kurento); do echo "Waiting for KMS..."; sleep 1; done' sh '/usr/bin/kurento-media-server &> /kms.log &'
sh(script: '''#!/bin/bash sh 'until $(curl --insecure --output /dev/null --silent http://127.0.0.1:8888/kurento); do echo "Waiting for KMS..."; sleep 1; done'
if [ "$DOCKER_RECORDING_VERSION" != "default" ]; then sh(script: '''#!/bin/bash
echo "Using custom openvidu-recording tag: $DOCKER_RECORDING_VERSION" if [ "$DOCKER_RECORDING_VERSION" != "default" ]; then
java -jar -DDOMAIN_OR_PUBLIC_IP=172.17.0.1 -DOPENVIDU_SECRET=MY_SECRET -DHTTPS_PORT=4443 -DOPENVIDU_RECORDING=true -DOPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/test-layouts -DOPENVIDU_RECORDING_VERSION=$DOCKER_RECORDING_VERSION -DOPENVIDU_WEBHOOK=true -DOPENVIDU_WEBHOOK_ENDPOINT=http://127.0.0.1:7777/webhook /opt/openvidu/openvidu-server-*.jar &> openvidu-server.log & echo "Using custom openvidu-recording tag: $DOCKER_RECORDING_VERSION"
else java -jar -DDOMAIN_OR_PUBLIC_IP=172.17.0.1 -DOPENVIDU_SECRET=MY_SECRET -DHTTPS_PORT=4443 -DOPENVIDU_RECORDING=true -DOPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/test-layouts -DOPENVIDU_RECORDING_VERSION=$DOCKER_RECORDING_VERSION -DOPENVIDU_WEBHOOK=true -DOPENVIDU_WEBHOOK_ENDPOINT=http://127.0.0.1:7777/webhook /opt/openvidu/openvidu-server-*.jar &> openvidu-server.log &
echo "Using default openvidu-recording tag" else
java -jar -DDOMAIN_OR_PUBLIC_IP=172.17.0.1 -DOPENVIDU_SECRET=MY_SECRET -DHTTPS_PORT=4443 -DOPENVIDU_RECORDING=true -DOPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/test-layouts -DOPENVIDU_WEBHOOK=true -DOPENVIDU_WEBHOOK_ENDPOINT=http://127.0.0.1:7777/webhook /opt/openvidu/openvidu-server-*.jar &> openvidu-server.log & echo "Using default openvidu-recording tag"
fi java -jar -DDOMAIN_OR_PUBLIC_IP=172.17.0.1 -DOPENVIDU_SECRET=MY_SECRET -DHTTPS_PORT=4443 -DOPENVIDU_RECORDING=true -DOPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/test-layouts -DOPENVIDU_WEBHOOK=true -DOPENVIDU_WEBHOOK_ENDPOINT=http://127.0.0.1:7777/webhook /opt/openvidu/openvidu-server-*.jar &> openvidu-server.log &
'''.stripIndent()) fi
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' '''.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') { stage ('OpenVidu E2E tests') {
try { try {