Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 127 additions & 107 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

pipeline {

agent {
label {
label params.nodeLabel
}
agent none

triggers {
// Run s390x builds every Sunday at midnight
cron('H 0 * * 0')
}

tools {
Expand All @@ -50,127 +51,146 @@ pipeline {
}

stages {
stage('Initialization') {
stage('Node selection') {
steps {
echo "running on ${env.NODE_NAME}"
echo 'Building branch ' + env.BRANCH_NAME
echo 'Using PATH ' + env.PATH
script {
// Detect if triggered by cron
def causes = currentBuild.getBuildCauses()
def triggeredByCron = causes.any { it._class == 'hudson.triggers.TimerTrigger$TimerTriggerCause' }

if (triggeredByCron) {
// Allow s390x builds only when triggered by the Sunday cron
targetNode = 's390x'
} else {
targetNode = params.nodeLabel
}
}
}
}
stage('Main Workflow') {
agent { label "${targetNode}" }
stages{
stage('Initialization') {
steps {
echo "running on ${env.NODE_NAME}"
echo 'Building branch ' + env.BRANCH_NAME
echo 'Using PATH ' + env.PATH
}
}

stage('Cleanup') {
steps {
echo 'Cleaning up the workspace'
deleteDir()
}
}
stage('Cleanup') {
steps {
echo 'Cleaning up the workspace'
deleteDir()
}
}

stage('Checkout') {
steps {
echo 'Checking out branch ' + env.BRANCH_NAME
checkout scm
}
}
stage('Checkout') {
steps {
echo 'Checking out branch ' + env.BRANCH_NAME
checkout scm
}
}

stage('Build JDK 24') {
tools {
jdk "jdk_24_latest"
}
steps {
echo 'Building JDK 24'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}
stage('Build JDK 24') {
tools {
jdk "jdk_24_latest"
}
steps {
echo 'Building JDK 24'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}

stage('Build JDK 21') {
tools {
jdk "jdk_21_latest"
}
steps {
echo 'Building JDK 21'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}
stage('Build JDK 21') {
tools {
jdk "jdk_21_latest"
}
steps {
echo 'Building JDK 21'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}

stage('Build JDK 17') {
tools {
jdk "jdk_17_latest"
}
steps {
echo 'Building JDK 17'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}
stage('Build JDK 17') {
tools {
jdk "jdk_17_latest"
}
steps {
echo 'Building JDK 17'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -U -B -e clean install -DskipTests'
}
}

stage('Verify') {
tools {
jdk params.jdkVersion
}
steps {
echo 'Running apache-rat:check'
sh 'java -version'
sh 'mvn -version'
sh 'mvn apache-rat:check'
}
}
stage('Verify') {
tools {
jdk params.jdkVersion
}
steps {
echo 'Running apache-rat:check'
sh 'java -version'
sh 'mvn -version'
sh 'mvn apache-rat:check'
}
}

stage('Tests') {
tools {
jdk params.jdkVersion
}
when { expression { return params.testsEnabled } }
steps {
echo 'Running tests'
sh 'java -version'
sh 'mvn -version'
// all tests is very very long (10 hours on Apache Jenkins)
// sh 'mvn -B -e test -pl activemq-unit-tests -Dactivemq.tests=all'
sh 'mvn -B -e -fae test -Dsurefire.rerunFailingTestsCount=3'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
stage('Tests') {
tools {
jdk params.jdkVersion
}
when { expression { return params.testsEnabled } }
steps {
echo 'Running tests'
sh 'java -version'
sh 'mvn -version'
// all tests is very very long (10 hours on Apache Jenkins)
// sh 'mvn -B -e test -pl activemq-unit-tests -Dactivemq.tests=all'
sh 'mvn -B -e -fae test -Dsurefire.rerunFailingTestsCount=3'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
}
}
}
}
}

stage('Deploy') {
tools {
jdk params.jdkVersion
}
when {
expression {
params.deployEnabled && env.BRANCH_NAME ==~ /(activemq-5.19.x|activemq-6.1.x|main)/
stage('Deploy') {
tools {
jdk params.jdkVersion
}
when {
expression {
params.deployEnabled && env.BRANCH_NAME ==~ /(activemq-5.19.x|activemq-6.1.x|main)/
}
}
steps {
echo 'Deploying'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -B -e deploy -Pdeploy -DskipTests'
}
}
}
steps {
echo 'Deploying'
sh 'java -version'
sh 'mvn -version'
sh 'mvn -B -e deploy -Pdeploy -DskipTests'
}
}

stage('Quality') {
when { expression { return params.sonarEnabled } }
stage('Quality') {
when { expression { return params.sonarEnabled } }

steps {
withCredentials([string(credentialsId: 'SONARCLOUD_TOKEN', variable: 'SONAR_TOKEN')]) {
sh 'echo "Running the Sonar stage"'
sh 'mvn -B -e -fae clean verify sonar:sonar -Dsonar.projectKey=apache_activemq -Dsonar.organization=apache -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -Dsurefire.rerunFailingTestsCount=3'
steps {
withCredentials([string(credentialsId: 'SONARCLOUD_TOKEN', variable: 'SONAR_TOKEN')]) {
sh 'echo "Running the Sonar stage"'
sh 'mvn -B -e -fae clean verify sonar:sonar -Dsonar.projectKey=apache_activemq -Dsonar.organization=apache -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -Dsurefire.rerunFailingTestsCount=3'
}
}
}
}
}

}

}
// Do any post build stuff ... such as sending emails depending on the overall build result.
post {
// If this build failed, send an email to the list.
Expand Down