Skip to content
Snippets Groups Projects
Commit e67a3401 authored by Philippe Larose's avatar Philippe Larose Committed by Sébastien Blin
Browse files

jenkins: Added unit test stage across supported Java versions

Ticket: https://redmine.savoirfairelinux.com/issues/7353
Change-Id: I148a9449409757160a415275c8576e10faf9a3ca
parent 748e4a88
Branches
No related tags found
No related merge requests found
...@@ -21,20 +21,49 @@ ...@@ -21,20 +21,49 @@
// - Docker plugin // - Docker plugin
// - ansicolor plugin // - ansicolor plugin
node('jami-jamsbuildvm-01') { node('jami-jamsbuildvm-01') {
// Get number of CPU available for the build // Get number of CPU available for the build
def cpuCount = sh returnStdout: true, script: 'nproc || echo -n 4' def cpuCount = sh returnStdout: true, script: 'nproc || echo -n 4'
def topDir = pwd() + '/jami-jams' def topDir = pwd() + '/jami-jams'
stage('SCM Checkout') { stage('SCM Checkout') {
deleteDir() deleteDir()
sh """ sh '''git clone --depth=1 --branch=master https://${RING_GERRIT_URL}/jami-jams'''
git clone --depth=1 --branch=master https://${RING_GERRIT_URL}/jami-jams }
"""
stage('Test') {
if (env.GERRIT_REFSPEC != null) {
dir(topDir) {
sh '''git fetch origin ${GERRIT_REFSPEC} && git checkout FETCH_HEAD'''
parallel(
"test-jdk-11": {
sh '''
docker build -f extras/CI/Dockerfile.test -t jams-test:11 --build-arg JAVA_VERSION=11 .
docker run jams-test:11 mvn verify
'''
},
"test-jdk-17": {
sh '''
docker build -f extras/CI/Dockerfile.test -t jams-test:17 --build-arg JAVA_VERSION=17 .
docker run jams-test:17 mvn verify
'''
},
"test-jdk-21": {
sh '''
docker build -f extras/CI/Dockerfile.test -t jams-test:21 --build-arg JAVA_VERSION=21 .
docker run jams-test:21 mvn verify
'''
},
failFast: true // Aborts the parallel steps if one of them fails
)
}
} else {
error "FAILED: I don't know what to test"
}
} }
if (env.BUILD_TYPE != ('default')) {
stage('Build') { stage('Build') {
if (env.GERRIT_REFSPEC != null) { if (env.GERRIT_REFSPEC != null) {
dir(topDir) { dir(topDir) {
...@@ -60,16 +89,14 @@ node('jami-jamsbuildvm-01') { ...@@ -60,16 +89,14 @@ node('jami-jamsbuildvm-01') {
stage('Deploy') { stage('Deploy') {
dir(topDir) { dir(topDir) {
sh """ sh '''tar -cvf jams.tar jams/*'''
tar -cvf jams.tar jams/*
"""
def DEPLOY_ENV_NAME = env.BUILD_TYPE.split("::")[0] def DEPLOY_ENV_NAME = env.BUILD_TYPE.split('::')[0]
def DEPLOY_ENV_IP = env.BUILD_TYPE.split("::")[1] def DEPLOY_ENV_IP = env.BUILD_TYPE.split('::')[1]
echo "Build type: ${env.BUILD_TYPE}" echo "Build type: ${env.BUILD_TYPE}"
echo "Build name: ${DEPLOY_ENV_NAME}" echo "Build name: ${DEPLOY_ENV_NAME}"
if(DEPLOY_ENV_NAME.equals("staging")){ if (DEPLOY_ENV_NAME.equals('staging')) {
sh """ sh """
scp -o StrictHostKeyChecking=no -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams-local scp -o StrictHostKeyChecking=no -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams-local
ssh root@${DEPLOY_ENV_IP} 'rm -rf /opt/jams-local/crl.pem' ssh root@${DEPLOY_ENV_IP} 'rm -rf /opt/jams-local/crl.pem'
...@@ -82,26 +109,20 @@ node('jami-jamsbuildvm-01') { ...@@ -82,26 +109,20 @@ node('jami-jamsbuildvm-01') {
ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-local' ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-local'
""" """
} }
if(DEPLOY_ENV_NAME.equals("qa")){ if (DEPLOY_ENV_NAME.equals('qa')) {
sh """ sh """
ls -la . ls -la .
scp -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams scp -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams
ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-prod' ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-prod'
""" """
} }
if(DEPLOY_ENV_NAME.equals("qa-local")){ if (DEPLOY_ENV_NAME.equals('qa-local')) {
sh """ sh """
scp -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams-local scp -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams-local
ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-local' ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-local'
""" """
} }
if(DEPLOY_ENV_NAME.equals("qa-ad")){ if (DEPLOY_ENV_NAME.equals('publish-update')) {
sh """
scp -r jams/* root@${DEPLOY_ENV_IP}:/opt/jams-local
ssh root@${DEPLOY_ENV_IP} 'systemctl restart jams-local'
"""
}
if(DEPLOY_ENV_NAME.equals("publish-update")){
sh """ sh """
ssh root@${DEPLOY_ENV_IP} 'rm -r /var/www/html/updates/' || true ssh root@${DEPLOY_ENV_IP} 'rm -r /var/www/html/updates/' || true
ssh root@${DEPLOY_ENV_IP} 'rm /var/www/html/versions.json' || true ssh root@${DEPLOY_ENV_IP} 'rm /var/www/html/versions.json' || true
...@@ -112,15 +133,14 @@ node('jami-jamsbuildvm-01') { ...@@ -112,15 +133,14 @@ node('jami-jamsbuildvm-01') {
scp versions.json root@${DEPLOY_ENV_IP}:/var/www/html/ scp versions.json root@${DEPLOY_ENV_IP}:/var/www/html/
""" """
} }
if(DEPLOY_ENV_NAME.equals("dl")){ if (DEPLOY_ENV_NAME.equals('dl')) {
def remoteHost = env.SSH_HOST_DL_RING_CX def remoteHost = env.SSH_HOST_DL_RING_CX
def remoteBaseDir = '/srv/repository/ring/jams' def remoteBaseDir = '/srv/repository/ring/jams'
def JENKINS_SSH_KEY = '35cefd32-dd99-41b0-8312-0b386df306ff' def JENKINS_SSH_KEY = '35cefd32-dd99-41b0-8312-0b386df306ff'
def DL_SSH_KEY = '5825b39b-dfc6-435f-918e-12acc1f56221' def DL_SSH_KEY = '5825b39b-dfc6-435f-918e-12acc1f56221'
sshagent(credentials: [JENKINS_SSH_KEY, DL_SSH_KEY]) { sshagent(credentials: [JENKINS_SSH_KEY, DL_SSH_KEY]) {
echo "Publishing to dl.jami.net..." echo 'Publishing to dl.jami.net...'
script { script {
sh """ sh """
tar -cvf jams.tar jams/* tar -cvf jams.tar jams/*
...@@ -141,4 +161,4 @@ node('jami-jamsbuildvm-01') { ...@@ -141,4 +161,4 @@ node('jami-jamsbuildvm-01') {
} }
} }
} }
}
ARG JAVA_VERSION=11
FROM maven:3.9.6-eclipse-temurin-${JAVA_VERSION}
WORKDIR /test
COPY pom.xml .
COPY ad-connector/pom.xml ad-connector/pom.xml
COPY authentication-module/pom.xml authentication-module/pom.xml
COPY datastore/pom.xml datastore/pom.xml
COPY jami-dht/pom.xml jami-dht/pom.xml
COPY jami-nameserver/pom.xml jami-nameserver/pom.xml
COPY jams-ca/pom.xml jams-ca/pom.xml
COPY jams-common/pom.xml jams-common/pom.xml
COPY jams-launcher/pom.xml jams-launcher/pom.xml
COPY ldap-connector/pom.xml ldap-connector/pom.xml
COPY jams-server/pom.xml jams-server/pom.xml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment