Jenkinsfile: parallel stages

pull/661/head
pabloFuente 2021-10-22 11:38:40 +02:00
parent 1a2dd5b203
commit 7b8afcc21a
1 changed files with 59 additions and 38 deletions

View File

@ -1,19 +1,36 @@
node('container') { node('container') {
sh 'docker rm -f e2e chrome firefox opera mediasoup || true' sh 'docker rm -f e2e chrome firefox opera mediasoup || true'
sh 'rm -rf /opt/openvidu/* || true' sh 'rm -rf /opt/openvidu/* || true'
sh 'wget https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/barcode.y4m -P /opt/openvidu' parallel (
sh 'wget https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/fakeaudio.wav -P /opt/openvidu' 'Download fake video': {
sh 'wget --directory-prefix=/opt/openvidu/test-layouts/layout1 https://raw.githubusercontent.com/OpenVidu/openvidu/master/openvidu-test-e2e/docker/my-custom-layout/index.html' sh 'wget https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/barcode.y4m -P /opt/openvidu'
},
docker.image('openvidu/openvidu-test-e2e:$DISTRO').pull() 'Download fake audio': {
docker.image('selenium/standalone-chrome:latest').pull() sh 'wget https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/fakeaudio.wav -P /opt/openvidu'
docker.image('selenium/standalone-firefox:latest').pull() },
docker.image('selenium/standalone-opera:latest').pull() 'Download custom layout': {
docker.image('openvidu/mediasoup-controller:$MEDIASOUP_CONTROLLER_DOCKER_VERSION').pull() sh 'wget --directory-prefix=/opt/openvidu/test-layouts/layout1 https://raw.githubusercontent.com/OpenVidu/openvidu/master/openvidu-test-e2e/docker/my-custom-layout/index.html'
}
)
parallel (
'Pull openvidu/openvidu-test-e2e': {
docker.image('openvidu/openvidu-test-e2e:$DISTRO').pull()
},
'Pull selenium/standalone-chrome': {
docker.image('selenium/standalone-chrome:latest').pull()
},
'Pull selenium/standalone-firefox': {
docker.image('selenium/standalone-firefox:latest').pull()
},
'Pull selenium/standalone-opera': {
docker.image('selenium/standalone-opera:latest').pull()
},
'Pull openvidu/mediasoup-controller': {
docker.image('openvidu/mediasoup-controller:$MEDIASOUP_CONTROLLER_DOCKER_VERSION').pull()
}
)
docker.image('openvidu/openvidu-test-e2e:$DISTRO').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') { docker.image('openvidu/openvidu-test-e2e:$DISTRO').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') { stage('Preparation') {
sh 'rm -rf ~/.m2 || true' sh 'rm -rf ~/.m2 || true'
sh 'rm -rf openvidu || true' sh 'rm -rf openvidu || true'
@ -40,32 +57,36 @@ node('container') {
'''.stripIndent()) '''.stripIndent())
} }
stage('OpenVidu Browser build') { parallel {
sh(script: '''#!/bin/bash -xe
cd openvidu stage('OpenVidu Browser build') {
if [[ $OPENVIDU_BROWSER_COMMIT != "default" ]]; then sh(script: '''#!/bin/bash -xe
git checkout -f $OPENVIDU_BROWSER_COMMIT cd openvidu
fi if [[ $OPENVIDU_BROWSER_COMMIT != "default" ]]; then
cd openvidu-browser git checkout -f $OPENVIDU_BROWSER_COMMIT
npm install --unsafe-perm && npm run build && npm pack fi
cp openvidu-browser-*.tgz /opt/openvidu cd openvidu-browser
cd .. npm install --unsafe-perm && npm run build && npm pack
git checkout -f $OPENVIDU_COMMIT cp openvidu-browser-*.tgz /opt/openvidu
'''.stripIndent()) cd ..
} git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
stage('OpenVidu Node Client build') {
sh(script: '''#!/bin/bash -xe
cd openvidu
if [[ $OPENVIDU_NODE_CLIENT_COMMIT != "default" ]]; then
git checkout -f $OPENVIDU_NODE_CLIENT_COMMIT
fi
cd openvidu-node-client
npm install --unsafe-perm && npm run build && npm pack
cp openvidu-node-client-*.tgz /opt/openvidu
cd ..
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
}
stage('OpenVidu Node Client build') {
sh(script: '''#!/bin/bash -xe
cd openvidu
if [[ $OPENVIDU_NODE_CLIENT_COMMIT != "default" ]]; then
git checkout -f $OPENVIDU_NODE_CLIENT_COMMIT
fi
cd openvidu-node-client
npm install --unsafe-perm && npm run build && npm pack
cp openvidu-node-client-*.tgz /opt/openvidu
cd ..
git checkout -f $OPENVIDU_COMMIT
'''.stripIndent())
} }
stage('OpenVidu TestApp build') { stage('OpenVidu TestApp build') {
@ -141,7 +162,7 @@ node('container') {
openViduE2ETest('kurento') openViduE2ETest('kurento')
} }
} catch (error) { } catch (error) {
echo "Test failed" echo 'Test failed'
currentBuild.result = 'FAILURE' currentBuild.result = 'FAILURE'
} finally { } finally {
// Kill all environment for next test // Kill all environment for next test
@ -159,7 +180,7 @@ node('container') {
openViduE2ETest('mediasoup') openViduE2ETest('mediasoup')
} }
} catch (error) { } catch (error) {
echo "Test failed" echo 'Test failed'
currentBuild.result = 'FAILURE' currentBuild.result = 'FAILURE'
} finally { } finally {
environmentStop() environmentStop()