Jenkinsfile: use maven settings so snapshots can be downloaded. Build kurento mvn build snapshots with only one thread to avoid github packages download restrictions

pull/732/head
cruizba 2022-06-01 10:47:04 +02:00
parent 4af8be5a72
commit bbb16189ef
1 changed files with 152 additions and 147 deletions

View File

@ -1,164 +1,169 @@
node('container') { node('container') {
// Load and execute common functions Groovy script
sh 'curl -O https://raw.githubusercontent.com/OpenVidu/openvidu/master/openvidu-test-e2e/jenkins/commonFunctions.groovy'
def commonFunctions = load 'commonFunctions.groovy'
commonFunctions.prepareTestingEnvironment()
// Clone and checkout OpenVidu/openvidu repository withEnv(["MVN_SETTINGS_VOLUME=/opt/openvidu-settings.xml",
def commitId = "${OPENVIDU_COMMIT}" 'MVN_OPTIONS=--settings /opt/openvidu-settings.xml -B']){
checkout([$class: 'GitSCM', branches: [[name: commitId]], userRemoteConfigs: [[url: 'https://github.com/OpenVidu/openvidu']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'openvidu']]]) // Load and execute common functions Groovy script
sh 'curl -O https://raw.githubusercontent.com/OpenVidu/openvidu/master/openvidu-test-e2e/jenkins/commonFunctions.groovy'
def commonFunctions = load 'commonFunctions.groovy'
commonFunctions.prepareTestingEnvironment()
// Volumes to use in container openvidu/openvidu-test-e2e // Clone and checkout OpenVidu/openvidu repository
def bindsArray = ['-v /var/run/docker.sock:/var/run/docker.sock:rw', def commitId = "${OPENVIDU_COMMIT}"
'-v /dev/shm:/dev/shm', checkout([$class: 'GitSCM', branches: [[name: commitId]], userRemoteConfigs: [[url: 'https://github.com/OpenVidu/openvidu']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'openvidu']]])
'-v /opt/openvidu:/opt/openvidu',
'-v /opt/openvidu-cache/test-layouts:/opt/openvidu/test-layouts',
'-v /opt/openvidu-cache/.m2:/root/.m2'].join(' ')
// Run openvidu/openvidu-test-e2e container // Volumes to use in container openvidu/openvidu-test-e2e
docker.image("openvidu/openvidu-test-e2e:${DISTRO}").inside('--privileged -p 4200:4200 -p 4443:4443 -p 4114:4114 -u root -e MY_UID=0 ' + "${bindsArray}") { def bindsArray = ['-v /var/run/docker.sock:/var/run/docker.sock:rw',
stage('Build 1') { '-v /dev/shm:/dev/shm',
parallel 'OpenVidu Browser build': { '-v /opt/openvidu:/opt/openvidu',
stage('OpenVidu Browser build') { '-v /opt/openvidu-cache/test-layouts:/opt/openvidu/test-layouts',
sh(script: '''#!/bin/bash -xe '-v /opt/openvidu-cache/.m2:/root/.m2',
cd openvidu/openvidu-browser "-v ${MAVEN_SETTINGS}:${MVN_SETTINGS_VOLUME}"].join(' ')
npm install --quiet --unsafe-perm
npm run build --quiet // Run openvidu/openvidu-test-e2e container
npm pack --quiet docker.image("openvidu/openvidu-test-e2e:${DISTRO}").inside('--privileged -p 4200:4200 -p 4443:4443 -p 4114:4114 -u root -e MY_UID=0 ' + "${bindsArray}") {
cp openvidu-browser-*.tgz /opt/openvidu stage('Build 1') {
'''.stripIndent()) parallel 'OpenVidu Browser build': {
} stage('OpenVidu Browser build') {
}, 'OpenVidu Node Client build': { sh(script: '''#!/bin/bash -xe
stage('OpenVidu Node Client build') { cd openvidu/openvidu-browser
sh(script: '''#!/bin/bash -xe npm install --quiet --unsafe-perm
cd openvidu/openvidu-node-client npm run build --quiet
npm install --quiet --unsafe-perm npm pack --quiet
npm run build --quiet cp openvidu-browser-*.tgz /opt/openvidu
npm pack --quiet '''.stripIndent())
cp openvidu-node-client-*.tgz /opt/openvidu }
'''.stripIndent()) }, 'OpenVidu Node Client build': {
} stage('OpenVidu Node Client build') {
}, 'OpenVidu Java Client build': { sh(script: '''#!/bin/bash -xe
stage('OpenVidu Java Client build') { cd openvidu/openvidu-node-client
sh(script: '''#!/bin/bash -xe npm install --quiet --unsafe-perm
cd openvidu/openvidu-java-client npm run build --quiet
mvn -B versions:set -DnewVersion=TEST npm pack --quiet
mvn -B clean compile package cp openvidu-node-client-*.tgz /opt/openvidu
mvn -B install:install-file -Dfile=target/openvidu-java-client-TEST.jar -DgroupId=io.openvidu -DartifactId=openvidu-java-client -Dversion=TEST -Dpackaging=jar '''.stripIndent())
'''.stripIndent()) }
}, 'OpenVidu Java Client build': {
stage('OpenVidu Java Client build') {
sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-java-client
mvn -B versions:set -DnewVersion=TEST
mvn -B clean compile package
mvn -B install:install-file -Dfile=target/openvidu-java-client-TEST.jar -DgroupId=io.openvidu -DartifactId=openvidu-java-client -Dversion=TEST -Dpackaging=jar
'''.stripIndent())
}
} }
} }
}
stage('Build 2') { stage('Build 2') {
parallel 'OpenVidu TestApp build': { parallel 'OpenVidu TestApp build': {
stage('OpenVidu TestApp build') { stage('OpenVidu TestApp build') {
sh(script: '''#!/bin/bash -xe sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-testapp cd openvidu/openvidu-testapp
npm install --force --unsafe-perm --quiet npm install --force --unsafe-perm --quiet
npm install /opt/openvidu/openvidu-browser-*.tgz --quiet
npm install /opt/openvidu/openvidu-node-client-*.tgz --quiet
export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng build --prod --output-path=/opt/openvidu/testapp
'''.stripIndent())
}
}, 'OpenVidu Server dashboard build': {
stage('OpenVidu Server dashboard build') {
sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-server/src/dashboard
npm install --unsafe-perm --quiet
npm install /opt/openvidu/openvidu-browser-*.tgz --quiet npm install /opt/openvidu/openvidu-browser-*.tgz --quiet
export NG_CLI_ANALYTICS="false" && npm run build-prod --quiet npm install /opt/openvidu/openvidu-node-client-*.tgz --quiet
'''.stripIndent()) export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng build --prod --output-path=/opt/openvidu/testapp
}
}, 'OpenVidu Server pre-build': {
stage('OpenVidu parent build') {
sh(script: '''#!/bin/bash -xe
if [[ ${KURENTO_JAVA_COMMIT} != "default" ]]; then
git clone https://github.com/Kurento/kurento-java.git
cd kurento-java
git checkout -f ${KURENTO_JAVA_COMMIT}
mvn -B clean install
MVN_VERSION=$(mvn -B -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
cd ../openvidu && mvn -B versions:set-property -Dproperty=version.kurento -DnewVersion=${MVN_VERSION}
fi
'''.stripIndent())
sh 'cd openvidu && mvn -B versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST'
sh 'cd openvidu && mvn -B -DskipTests=true clean install'
}
stage('OpenVidu Server unit tests') {
sh 'cd openvidu/openvidu-server && mvn -B -Dtest=io.openvidu.server.test.unit.*Test test'
}
stage('OpenVidu Server integration tests') {
sh 'cd openvidu/openvidu-server && mvn -B -Dtest=io.openvidu.server.test.integration.*Test test'
}
stage('OpenVidu Test E2E build') {
sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-test-browsers
mvn -B versions:set -DnewVersion=TEST && mvn -B clean install
cd ..
mvn -B versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST
mvn -B versions:set-property -Dproperty=version.openvidu.test.browsers -DnewVersion=TEST
cd openvidu-test-e2e
mvn -B -DskipTests=true clean install
'''.stripIndent()) '''.stripIndent())
}
}, 'OpenVidu Server dashboard build': {
stage('OpenVidu Server dashboard build') {
sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-server/src/dashboard
npm install --unsafe-perm --quiet
npm install /opt/openvidu/openvidu-browser-*.tgz --quiet
export NG_CLI_ANALYTICS="false" && npm run build-prod --quiet
'''.stripIndent())
}
}, 'OpenVidu Server pre-build': {
stage('OpenVidu parent build') {
sh(script: '''#!/bin/bash -xe
if [[ ${KURENTO_JAVA_COMMIT} != "default" ]]; then
git clone https://github.com/Kurento/kurento-java.git
cd kurento-java
git checkout -f ${KURENTO_JAVA_COMMIT}
MVN_VERSION="$(grep -oPm1 "(?<=<version>)[^<]+" "pom.xml")"
mvn ${MVN_OPTIONS} -Dmaven.artifact.threads=1 clean install
cd ../openvidu && mvn ${MVN_OPTIONS} versions:set-property -Dproperty=version.kurento -DnewVersion=${MVN_VERSION}
fi
'''.stripIndent())
sh 'cd openvidu && mvn ${MVN_OPTIONS} versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST'
sh 'cd openvidu && mvn ${MVN_OPTIONS} -DskipTests=true clean install'
}
stage('OpenVidu Server unit tests') {
sh 'cd openvidu/openvidu-server && mvn ${MVN_OPTIONS} -Dtest=io.openvidu.server.test.unit.*Test test'
}
stage('OpenVidu Server integration tests') {
sh 'cd openvidu/openvidu-server && mvn ${MVN_OPTIONS} -Dtest=io.openvidu.server.test.integration.*Test test'
}
stage('OpenVidu Test E2E build') {
sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-test-browsers
mvn ${MVN_OPTIONS} versions:set -DnewVersion=TEST && mvn ${MVN_OPTIONS} clean install
cd ..
mvn ${MVN_OPTIONS} versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST
mvn ${MVN_OPTIONS} versions:set-property -Dproperty=version.openvidu.test.browsers -DnewVersion=TEST
cd openvidu-test-e2e
mvn ${MVN_OPTIONS} -DskipTests=true clean install
'''.stripIndent())
}
} }
} }
}
stage('OpenVidu Server build') { stage('OpenVidu Server build') {
sh(script: '''#!/bin/bash -xe sh(script: '''#!/bin/bash -xe
cd openvidu/openvidu-server cd openvidu/openvidu-server
mvn -B -DskipTests=true package mvn ${MVN_OPTIONS} -DskipTests=true package
cp target/openvidu-server*.jar /opt/openvidu cp target/openvidu-server*.jar /opt/openvidu
'''.stripIndent()) '''.stripIndent())
}
// Kurento tests
stage ('Environment Launch Kurento') {
environmentLaunch('kurento')
}
try {
stage ('OpenVidu Kurento E2E tests') {
try {
openViduE2ETest("${KURENTO_MEDIA_SERVER_IMAGE}")
} catch (err) {
// In case of error, fail the stage
sh 'exit 1'
} finally {
junit 'openvidu/openvidu-test-e2e/**/target/surefire-reports/TEST-*.xml'
archiveArtifacts artifacts: '**/openvidu-server-*.log'
}
} }
} catch (error) {
echo 'Test failed'
currentBuild.result = 'FAILURE'
} finally {
// Kill all environment for next test
environmentStop()
}
// Mediasoup tests // Kurento tests
stage ('Environment Launch Mediasoup') { stage ('Environment Launch Kurento') {
environmentLaunch('mediasoup') environmentLaunch('kurento')
} }
try { try {
stage ('OpenVidu Mediasoup E2E tests') { stage ('OpenVidu Kurento E2E tests') {
try { try {
openViduE2ETest("openvidu/mediasoup-controller:${MEDIASOUP_CONTROLLER_VERSION}") openViduE2ETest("${KURENTO_MEDIA_SERVER_IMAGE}")
} catch (err) { } catch (err) {
// In case of error, fail the stage // In case of error, fail the stage
sh 'exit 1' sh 'exit 1'
} finally { } finally {
junit 'openvidu/openvidu-test-e2e/**/target/surefire-reports/TEST-*.xml' junit 'openvidu/openvidu-test-e2e/**/target/surefire-reports/TEST-*.xml'
archiveArtifacts artifacts: '**/openvidu-server-*.log' archiveArtifacts artifacts: '**/openvidu-server-*.log'
} }
}
} catch (error) {
echo 'Test failed'
currentBuild.result = 'FAILURE'
} finally {
// Kill all environment for next test
environmentStop()
}
// Mediasoup tests
stage ('Environment Launch Mediasoup') {
environmentLaunch('mediasoup')
}
try {
stage ('OpenVidu Mediasoup E2E tests') {
try {
openViduE2ETest("openvidu/mediasoup-controller:${MEDIASOUP_CONTROLLER_VERSION}")
} catch (err) {
// In case of error, fail the stage
sh 'exit 1'
} finally {
junit 'openvidu/openvidu-test-e2e/**/target/surefire-reports/TEST-*.xml'
archiveArtifacts artifacts: '**/openvidu-server-*.log'
}
}
} catch (error) {
echo 'Test failed'
currentBuild.result = 'FAILURE'
} finally {
environmentStop()
commonFunctions.removeStrandedContainers(false)
} }
} catch (error) {
echo 'Test failed'
currentBuild.result = 'FAILURE'
} finally {
environmentStop()
commonFunctions.removeStrandedContainers(false)
} }
} }
} }
@ -229,7 +234,7 @@ def openViduE2ETest(mediaServerImage) {
if [[ $mediaServerImage == *"openvidu/mediasoup-controller"* ]]; then if [[ $mediaServerImage == *"openvidu/mediasoup-controller"* ]]; then
ENV_VARS+=" -DOPENVIDU_PRO_LICENSE=${openviduProLicense} -DOPENVIDU_PRO_LICENSE_API=${openviduProLicenseApi}" ENV_VARS+=" -DOPENVIDU_PRO_LICENSE=${openviduProLicense} -DOPENVIDU_PRO_LICENSE_API=${openviduProLicenseApi}"
fi fi
sudo mvn -B ${ENV_VARS} test sudo mvn ${MVN_OPTIONS} ${ENV_VARS} test
'''.stripIndent()) '''.stripIndent())
} }
} }