diff --git a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile index bed05e9ed4..c0c7a4ca6d 100644 --- a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile +++ b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile @@ -56,21 +56,33 @@ pipeline { ) string( // Note: need to update 'verify-parameters' entries if you add new platform(s) name: 'BUILD_PLATFORM', - description: 'Build selected platform related artifacts, choices include linux windows. Can combine multiple platforms with space in between (docker is only available on linux)', + description: "Build selected platform, choices include 'linux', 'windows'. Can combine multiple platforms with space in between (docker is only available on linux)", defaultValue: 'linux windows', trim: true ) - string( - name: 'RC_NUMBER', - description: 'The RC build count. Default is 0 which means its not an RC build.', - defaultValue: '0' - ) string( // Note: need to update 'verify-parameters' entries if you add new distribution(s) name: 'BUILD_DISTRIBUTION', - description: 'Build selected distribution related artifacts, choices include tar, rpm, deb, zip. Can combine multiple distributions with space in between (docker is only available on tar)', + description: "Build selected distribution, choices include 'tar', 'rpm', 'deb', 'zip'. Can combine multiple distributions with space in between (docker is only available on tar)", defaultValue: 'tar rpm deb zip', trim: true ) + string( // Note: need to update 'verify-parameters' entries if you add new platform(s) + name: 'TEST_PLATFORM', + description: "Test selected platform, choices include 'linux', 'windows'. Can combine multiple platforms with space in between (docker is only available on linux)", + defaultValue: 'linux windows', + trim: true + ) + string( // Note: need to update 'verify-parameters' entries if you add new distribution(s) + name: 'TEST_DISTRIBUTION', + description: "Build selected distribution, choices include 'tar', 'rpm', 'deb', 'zip'. Can combine multiple distributions with space in between (docker is only available on tar)", + defaultValue: 'tar rpm deb zip', + trim: true + ) + string( + name: 'RC_NUMBER', + description: 'The RC build count. Default is 0 which means its not an RC build.', + defaultValue: '0' + ) choice( name: 'BUILD_DOCKER', description: 'Build docker image or not with options.', @@ -124,40 +136,15 @@ pipeline { dockerAgent = detectDockerAgent() currentBuild.description = INPUT_MANIFEST - echo('Verify Build Platforms') - def build_platform_array = params.BUILD_PLATFORM.tokenize(' ') - echo("User Entry Platforms: '${params.BUILD_PLATFORM}', ${build_platform_array}") - def all_platforms = 'linux windows' - echo("All Supported Platforms: '${all_platforms}'") - - if (params.BUILD_PLATFORM == null || params.BUILD_PLATFORM == '') { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_PLATFORM (possible entries: ${all_platforms}).") - } - - for (String plat : build_platform_array) { - if (! all_platforms.contains(plat)) { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_PLATFORM (possible entries: ${all_platforms}).") - } - } - - echo('Verify Build Distributions') - def build_distribution_array = params.BUILD_DISTRIBUTION.tokenize(' ') - echo("User Entry Distributions: '${params.BUILD_DISTRIBUTION}', ${build_distribution_array}") - def all_distributions = 'tar rpm deb zip' - echo("All Supported Platforms: '${all_distributions}'") + paramType = [ + 'BUILD_PLATFORM': 'linux windows', + 'BUILD_DISTRIBUTION': 'tar rpm deb zip', + 'TEST_PLATFORM': 'linux windows', + 'TEST_DISTRIBUTION': 'tar rpm deb zip', + ] - if (params.BUILD_DISTRIBUTION == null || params.BUILD_DISTRIBUTION == '') { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_DISTRIBUTION (possible entries: ${all_distributions}).") - } - - for (String plat : build_distribution_array) { - if (! all_distributions.contains(plat)) { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_DISTRIBUTION (possible entries: ${all_distributions}).") - } + paramType.each { key, value -> + verifyParameterPlatformDistribution(key, value) } } } @@ -208,10 +195,10 @@ pipeline { parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'tar') }, 'bwc-test': { - triggerBWCTests(buildManifestUrl) + triggerBWCTests(buildManifestUrl, 'linux', 'tar') } ]) } @@ -328,7 +315,7 @@ pipeline { String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'rpm') }, 'rpm-validation': { triggerRpmValidation(bundleManifestUrl) @@ -443,7 +430,8 @@ pipeline { echo "buildManifestUrl (linux, x64, deb): ${buildManifestUrl}" echo "artifactUrl (linux, x64, deb): ${artifactUrl}" - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'deb') } } post { @@ -559,10 +547,10 @@ pipeline { parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'tar') }, 'bwc-test': { - triggerBWCTests(buildManifestUrl) + triggerBWCTests(buildManifestUrl, 'linux', 'tar') } ]) } @@ -679,7 +667,7 @@ pipeline { String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'rpm') }, 'rpm-validation': { triggerRpmValidation(bundleManifestUrl) @@ -794,7 +782,8 @@ pipeline { echo "buildManifestUrl (linux, arm64, deb): ${buildManifestUrl}" echo "artifactUrl (linux, arm64, deb): ${artifactUrl}" - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'linux', 'deb') } } post { @@ -866,7 +855,8 @@ pipeline { echo "buildManifestUrl (windows, x64, zip): ${buildManifestUrl}" echo "artifactUrl (windows, x64, zip): ${artifactUrl}" - triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch) + + triggerIntegrationTests(buildManifestUrl, buildManifestUrlOpenSearch, 'windows', 'zip') } } post { @@ -1033,9 +1023,9 @@ def markStageUnstableIfPluginsFailedToBuild() { } } -def triggerIntegrationTests(String buildManifestUrl, String buildManifestUrlOpenSearch) { - Boolean skipIntegTests = (INTEG_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '' || buildManifestUrlOpenSearch == '') - echo "${skipIntegTests ? 'Skipping integration tests as one of the values has empty string: INTEG_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl, buildManifestUrlOpenSearch' : 'Running integration tests'}" +def triggerIntegrationTests(String buildManifestUrl, String buildManifestUrlOpenSearch, String platform, String distribution) { + Boolean skipIntegTests = (INTEG_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '' || buildManifestUrlOpenSearch == '' || !TEST_PLATFORM.contains(platform) || !TEST_DISTRIBUTION.contains(distribution)) + echo "${skipIntegTests ? 'Skipping INTEG tests as one of the values has empty or wrong string: INTEG_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl, buildManifestUrlOpenSearch, TEST_PLATFORM, TEST_DISTRIBUTION' : 'Running INTEG tests'}" if (!skipIntegTests) { def integTestResults = build job: INTEG_TEST_JOB_NAME, @@ -1051,9 +1041,9 @@ def triggerIntegrationTests(String buildManifestUrl, String buildManifestUrlOpen } } -def triggerBWCTests(String buildManifestUrl) { - Boolean skipBwcTests = (BWC_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '') - echo "${skipBwcTests ? 'Skipping BWC tests as one of the values has empty string: BWC_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl' : 'Running BWC tests'}" +def triggerBWCTests(String buildManifestUrl, String platform, String distribution) { + Boolean skipBwcTests = (BWC_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '' || !TEST_PLATFORM.contains(platform) || !TEST_DISTRIBUTION.contains(distribution)) + echo "${skipBwcTests ? 'Skipping BWC tests as one of the values has empty or wrong string: BWC_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl, TEST_PLATFORM, TEST_DISTRIBUTION' : 'Running BWC tests'}" if (!skipBwcTests) { def bwcTestResults = build job: BWC_TEST_JOB_NAME, @@ -1082,3 +1072,25 @@ def triggerRpmValidation(String bundleManifestUrl) { def addMessageToNotificationQueue() { lib.jenkins.Messages.new(this).add("${STAGE_NAME}", lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])) } + +def verifyParameterPlatformDistribution(String paramName, String allowedValue) { + echo("Verify Parameter '$paramName'") + def paramValue = env."$paramName" + def checkArray = paramValue.tokenize(' ') + echo("Parameter Entry: '$paramValue', $checkArray") + echo("Supported Entry: '$allowedValue'") + + if (paramValue == null || paramValue == '') { + currentBuild.result = 'ABORTED' + error("Missing parameter '$paramName' (possible entries: $allowedValue).") + } + + for (String entry : paramValue) { + if (! allowedValue.contains(entry)) { + currentBuild.result = 'ABORTED' + error("Error parameter '$paramName': $paramValue (possible entries: ${allowedValue}).") + } + } + + echo("Verified '$paramName': $paramValue\n") +} diff --git a/jenkins/opensearch/distribution-build.jenkinsfile b/jenkins/opensearch/distribution-build.jenkinsfile index 77058a540b..7aa29d0f46 100644 --- a/jenkins/opensearch/distribution-build.jenkinsfile +++ b/jenkins/opensearch/distribution-build.jenkinsfile @@ -55,8 +55,26 @@ pipeline { ) string( // Note: need to update 'verify-parameters' entries if you add new platform(s) name: 'BUILD_PLATFORM', - description: "Build selected platform related artifacts, choices include 'linux', 'macos', 'windows'. Can combine multiple platforms with space in between (maven snapshot is only on linux)", - defaultValue: 'linux macos windows', + description: "Build selected platform, choices include 'linux', 'windows'. Can combine multiple platforms with space in between (docker is only available on linux)", + defaultValue: 'linux windows', + trim: true + ) + string( // Note: need to update 'verify-parameters' entries if you add new distribution(s) + name: 'BUILD_DISTRIBUTION', + description: "Build selected distribution, choices include 'tar', 'rpm', 'deb', 'zip'. Can combine multiple distributions with space in between (docker is only available on tar)", + defaultValue: 'tar rpm deb zip', + trim: true + ) + string( // Note: need to update 'verify-parameters' entries if you add new platform(s) + name: 'TEST_PLATFORM', + description: "Test selected platform, choices include 'linux', 'windows'. Can combine multiple platforms with space in between (docker is only available on linux)", + defaultValue: 'linux windows', + trim: true + ) + string( // Note: need to update 'verify-parameters' entries if you add new distribution(s) + name: 'TEST_DISTRIBUTION', + description: "Build selected distribution, choices include 'tar', 'rpm', 'deb', 'zip'. Can combine multiple distributions with space in between (docker is only available on tar)", + defaultValue: 'tar rpm deb zip', trim: true ) string( @@ -118,22 +136,15 @@ pipeline { env.javaVersionNumber = dockerAgent.javaVersion.replaceAll('[^0-9]', '') // Only get number currentBuild.description = INPUT_MANIFEST - echo('Verify Build Platforms') - def build_platform_array = params.BUILD_PLATFORM.tokenize(' ') - echo("User Entry Platforms: '${params.BUILD_PLATFORM}', ${build_platform_array}") - def all_platforms = 'linux macos windows' - echo("All Supported Platforms: '${all_platforms}'") - - if (params.BUILD_PLATFORM == null || params.BUILD_PLATFORM == '') { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_PLATFORM (possible entries: ${all_platforms}).") - } + paramType = [ + 'BUILD_PLATFORM': 'linux windows', + 'BUILD_DISTRIBUTION': 'tar rpm deb zip', + 'TEST_PLATFORM': 'linux windows', + 'TEST_DISTRIBUTION': 'tar rpm deb zip', + ] - for (String plat : build_platform_array) { - if (! all_platforms.contains(plat)) { - currentBuild.result = 'ABORTED' - error("Missing parameter: BUILD_PLATFORM (possible entries: ${all_platforms}).") - } + paramType.each { key, value -> + verifyParameterPlatformDistribution(key, value) } } } @@ -167,6 +178,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('tar') + } } agent { docker { @@ -199,24 +213,12 @@ pipeline { parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl) + triggerIntegrationTests(buildManifestUrl, 'linux', 'tar') }, 'bwc-test': { - Boolean skipBwcTests = (BWC_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '') - echo "${skipBwcTests ? 'Skipping BWC tests as one of the values has empty string: BWC_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl' : 'Running BWC tests'}" - if (!skipBwcTests) { - def bwcTestResults = - build job: BWC_TEST_JOB_NAME, - propagate: false, - wait: false, - parameters: [ - string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), - string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), - string(name: 'AGENT_LABEL', value: AGENT_LINUX_X64) - ] - } + triggerBWCTests(buildManifestUrl, 'linux', 'tar') } - ]) + ]) } } post { @@ -258,6 +260,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('rpm') + } } agent { label AGENT_LINUX_X64 } stages { @@ -328,7 +333,7 @@ pipeline { String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl) + triggerIntegrationTests(buildManifestUrl, 'linux', 'rpm') }, 'rpm-validation': { triggerRpmValidation(bundleManifestUrl) @@ -374,6 +379,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('deb') + } } agent { label AGENT_LINUX_X64 } stages { @@ -442,7 +450,8 @@ pipeline { echo "artifactUrl (linux, x64, deb): ${artifactUrl}" String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) - triggerIntegrationTests(buildManifestUrl) + + triggerIntegrationTests(buildManifestUrl, 'linux', 'deb') } } post { @@ -484,6 +493,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('tar') + } } agent { docker { @@ -513,7 +525,8 @@ pipeline { echo "buildManifestUrl (linux, arm64, tar): ${buildManifestUrl}" echo "artifactUrl (linux, arm64, tar): ${artifactUrl}" - triggerIntegrationTests(buildManifestUrl) + + triggerIntegrationTests(buildManifestUrl, 'linux', 'tar') } } post { @@ -555,6 +568,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('rpm') + } } agent { label AGENT_LINUX_X64 } stages { @@ -625,7 +641,7 @@ pipeline { String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) parallel([ 'integ-test': { - triggerIntegrationTests(buildManifestUrl) + triggerIntegrationTests(buildManifestUrl, 'linux', 'rpm') }, 'rpm-validation': { triggerRpmValidation(bundleManifestUrl) @@ -671,6 +687,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('linux') } + expression { + params.BUILD_DISTRIBUTION.contains('deb') + } } agent { label AGENT_LINUX_ARM64 } @@ -740,7 +759,8 @@ pipeline { echo "artifactUrl (linux, arm64, deb): ${artifactUrl}" String bundleManifestUrl = buildManifestObj.getBundleManifestUrl(JOB_NAME, BUILD_NUMBER) - triggerIntegrationTests(buildManifestUrl) + + triggerIntegrationTests(buildManifestUrl, 'linux', 'deb') } } post { @@ -781,6 +801,9 @@ pipeline { expression { params.BUILD_PLATFORM.contains('windows') } + expression { + params.BUILD_DISTRIBUTION.contains('zip') + } } agent { docker { @@ -811,7 +834,8 @@ pipeline { echo "buildManifestUrl (windows, x64, zip): ${buildManifestUrl}" echo "artifactUrl (windows, x64, zip): ${artifactUrl}" - triggerIntegrationTests(buildManifestUrl) + + triggerIntegrationTests(buildManifestUrl, 'windows', 'zip') } } post { @@ -972,9 +996,9 @@ def markStageUnstableIfPluginsFailedToBuild() { } } -def triggerIntegrationTests(String buildManifestUrl) { - Boolean skipIntegTests = (INTEG_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '') - echo "${skipIntegTests ? 'Skipping integration tests as one of the values has empty string: INTEG_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl' : 'Running integration tests'}" +def triggerIntegrationTests(String buildManifestUrl, String platform, String distribution) { + Boolean skipIntegTests = (INTEG_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '' || !TEST_PLATFORM.contains(platform) || !TEST_DISTRIBUTION.contains(distribution)) + echo "${skipIntegTests ? 'Skipping INTEG tests as one of the values has empty or wrong string: INTEG_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl, TEST_PLATFORM, TEST_DISTRIBUTION' : 'Running INTEG tests'}" if (!skipIntegTests) { def integTestResults = build job: INTEG_TEST_JOB_NAME, @@ -989,6 +1013,22 @@ def triggerIntegrationTests(String buildManifestUrl) { } } +def triggerBWCTests(String buildManifestUrl, String platform, String distribution) { + Boolean skipBwcTests = (BWC_TEST_JOB_NAME == '' || TEST_MANIFEST == '' || buildManifestUrl == '' || !TEST_PLATFORM.contains(platform) || !TEST_DISTRIBUTION.contains(distribution)) + echo "${skipBwcTests ? 'Skipping BWC tests as one of the values has empty or wrong string: BWC_TEST_JOB_NAME, TEST_MANIFEST, buildManifestUrl, TEST_PLATFORM, TEST_DISTRIBUTION' : 'Running BWC tests'}" + if (!skipBwcTests) { + def bwcTestResults = + build job: BWC_TEST_JOB_NAME, + propagate: false, + wait: false, + parameters: [ + string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), + string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), + string(name: 'AGENT_LABEL', value: AGENT_LINUX_X64) + ] + } +} + def triggerRpmValidation(String bundleManifestUrl) { echo "Triggering RPM validation for ${bundleManifestUrl}" def rpmValidationResults = @@ -1000,3 +1040,25 @@ def triggerRpmValidation(String bundleManifestUrl) { string(name: 'AGENT_LABEL', value: AGENT_LINUX_X64) ] } + +def verifyParameterPlatformDistribution(String paramName, String allowedValue) { + echo("Verify Parameter '$paramName'") + def paramValue = env."$paramName" + def checkArray = paramValue.tokenize(' ') + echo("Parameter Entry: '$paramValue', $checkArray") + echo("Supported Entry: '$allowedValue'") + + if (paramValue == null || paramValue == '') { + currentBuild.result = 'ABORTED' + error("Missing parameter '$paramName' (possible entries: $allowedValue).") + } + + for (String entry : paramValue) { + if (! allowedValue.contains(entry)) { + currentBuild.result = 'ABORTED' + error("Error parameter '$paramName': $paramValue (possible entries: ${allowedValue}).") + } + } + + echo("Verified '$paramName': $paramValue\n") +}