Skip to content

Commit

Permalink
Jenkins: separate build pipeline and package test pipeline
Browse files Browse the repository at this point in the history
The build pipeline used to build clamav packages and then test those
packages with a rudimentary test set. This change will build the clamav
packages in one pipeline - then test the packages in a new test pipeline.

The new test pipeline will use the larger test suite that we use for
testing from-source builds in the "regular" test pipeline.
  • Loading branch information
micahsnyder committed May 22, 2024
1 parent 18f2916 commit 55fd9d4
Showing 1 changed file with 43 additions and 10 deletions.
53 changes: 43 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@ properties(
description: 'test-framework branch'),
string(name: 'TESTS_BRANCH',
defaultValue: '1.4',
description: 'tests branch'),
description: 'tests branch for the package and regular tests'),
string(name: 'TESTS_CUSTOM_BRANCH',
defaultValue: '1.4',
description: 'tests-custom branch'),
string(name: 'TESTS_FUZZ_BRANCH',
defaultValue: '1.4',
description: 'tests-fuzz-regression branch'),
string(name: 'BUILD_PIPELINES_PATH',
defaultValue: 'ClamAV/build-pipelines',
description: 'build-pipelines path for clamav in Jenkins'),
string(name: 'TEST_PIPELINES_PATH',
defaultValue: 'ClamAV/test-pipelines',
description: 'test-pipelines path for clamav in Jenkins'),
string(name: 'BUILD_PIPELINE',
defaultValue: 'build-1.4',
description: 'test-pipelines branch for build acceptance'),
string(name: 'PACKAGE_PIPELINE',
defaultValue: 'package-1.4',
description: 'test-pipelines branch for package tests.'),
string(name: 'REGULAR_PIPELINE',
defaultValue: 'regular-1.4',
description: 'test-pipelines branch for regular tests.'),
Expand All @@ -50,7 +56,7 @@ properties(
]
)

node('ubuntu-18-x64') {
node('default') {
stage('Generate Tarball') {
cleanWs()

Expand Down Expand Up @@ -82,32 +88,57 @@ node('ubuntu-18-x64') {
def buildResult

stage('Build') {
buildResult = build(job: "${params.TEST_PIPELINES_PATH}/${params.BUILD_PIPELINE}",
buildResult = build(job: "${params.BUILD_PIPELINES_PATH}/${params.BUILD_PIPELINE}",
propagate: true,
wait: true,
parameters: [
[$class: 'StringParameterValue', name: 'PIPELINE_BRANCH_NAME', value: "${params.BUILD_PIPELINE}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NAME', value: "${JOB_NAME}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NUMBER', value: "${BUILD_NUMBER}"],
[$class: 'StringParameterValue', name: 'FRAMEWORK_BRANCH', value: "${params.FRAMEWORK_BRANCH}"],
[$class: 'StringParameterValue', name: 'VERSION', value: "${params.VERSION}"],
[$class: 'StringParameterValue', name: 'SHARED_LIB_BRANCH', value: "${params.SHARED_LIB_BRANCH}"]
]
)
echo "${params.TEST_PIPELINES_PATH}/${params.BUILD_PIPELINE} #${buildResult.number} succeeded."
echo "${params.BUILD_PIPELINES_PATH}/${params.BUILD_PIPELINE} #${buildResult.number} succeeded."
}

stage('Test') {
def tasks = [:]

tasks["regular_and_custom"] = {
def regularResult
tasks["package_regular_custom"] = {
def exception = null
try {
stage("Regular Pipeline") {
regularResult = build(job: "${params.TEST_PIPELINES_PATH}/${params.REGULAR_PIPELINE}",
stage("Package") {
final regularResult = build(job: "${params.TEST_PIPELINES_PATH}/${params.PACKAGE_PIPELINE}",
propagate: true,
wait: true,
parameters: [
[$class: 'StringParameterValue', name: 'PIPELINE_BRANCH_NAME', value: "${params.PACKAGE_PIPELINE}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NAME', value: "${JOB_NAME}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NUMBER', value: "${BUILD_NUMBER}"],
[$class: 'StringParameterValue', name: 'BUILD_JOB_NAME', value: "${params.TEST_PIPELINES_PATH}/${params.BUILD_PIPELINE}"],
[$class: 'StringParameterValue', name: 'BUILD_JOB_NUMBER', value: "${buildResult.number}"],
[$class: 'StringParameterValue', name: 'TESTS_BRANCH', value: "${params.TESTS_BRANCH}"],
[$class: 'StringParameterValue', name: 'FRAMEWORK_BRANCH', value: "${params.FRAMEWORK_BRANCH}"],
[$class: 'StringParameterValue', name: 'VERSION', value: "${params.VERSION}"],
[$class: 'StringParameterValue', name: 'SHARED_LIB_BRANCH', value: "${params.SHARED_LIB_BRANCH}"]
]
)
echo "${params.TEST_PIPELINES_PATH}/${params.PACKAGE_PIPELINE} #${regularResult.number} succeeded."
}
} catch (exc) {
echo "${params.TEST_PIPELINES_PATH}/${params.PACKAGE_PIPELINE} failed."
exception = exc
}

try {
stage("Regular From-Source") {
final regularResult = build(job: "${params.TEST_PIPELINES_PATH}/${params.REGULAR_PIPELINE}",
propagate: true,
wait: true,
parameters: [
[$class: 'StringParameterValue', name: 'PIPELINE_BRANCH_NAME', value: "${params.REGULAR_PIPELINE}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NAME', value: "${JOB_NAME}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NUMBER', value: "${BUILD_NUMBER}"],
[$class: 'StringParameterValue', name: 'BUILD_JOB_NAME', value: "${params.TEST_PIPELINES_PATH}/${params.BUILD_PIPELINE}"],
Expand All @@ -124,11 +155,13 @@ node('ubuntu-18-x64') {
echo "${params.TEST_PIPELINES_PATH}/${params.REGULAR_PIPELINE} failed."
exception = exc
}
stage("Custom Pipeline") {

stage("Custom From-Source") {
final customResult = build(job: "${params.TEST_PIPELINES_PATH}/${params.CUSTOM_PIPELINE}",
propagate: true,
wait: true,
parameters: [
[$class: 'StringParameterValue', name: 'PIPELINE_BRANCH_NAME', value: "${params.CUSTOM_PIPELINE}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NAME', value: "${JOB_NAME}"],
[$class: 'StringParameterValue', name: 'CLAMAV_JOB_NUMBER', value: "${BUILD_NUMBER}"],
[$class: 'StringParameterValue', name: 'TESTS_BRANCH', value: "${params.TESTS_CUSTOM_BRANCH}"],
Expand All @@ -140,7 +173,7 @@ node('ubuntu-18-x64') {
echo "${params.TEST_PIPELINES_PATH}/${params.CUSTOM_PIPELINE} #${customResult.number} succeeded."
}
if(exception != null) {
echo "Custom Pipeline passed, but Regular pipeline failed!"
echo "Custom Pipeline passed, but prior pipelines failed!"
throw exception
}
}
Expand Down

0 comments on commit 55fd9d4

Please sign in to comment.