lib = library(identifier: 'jenkins@1.0.4', retriever: modernSCM([ $class: 'GitSCMSource', remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git', ])) pipeline { options { timeout(time: 3, unit: 'HOURS') } agent none environment { BUILD_MANIFEST = "build-manifest.yml" DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch" } parameters { string( name: 'TEST_MANIFEST', description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0-test.yml.', trim: true ) string( name: 'BUILD_MANIFEST_URL', description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.2/98/linux/x64/builds/opensearch/manifest.yml.', trim: true ) string( name: 'AGENT_LABEL', description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host.', trim: true ) } stages { stage('verify-parameters') { agent { node { label AGENT_LABEL } } steps { script { currentBuild.description = TEST_MANIFEST if (AGENT_LABEL == '') { currentBuild.result = 'ABORTED' error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.") } if (TEST_MANIFEST == '' || !fileExists("manifests/${TEST_MANIFEST}")) { currentBuild.result = 'ABORTED' error("BWC Tests failed to start. Test manifest not was provided or not found in manifests/${TEST_MANIFEST}.") } /* Rebuilding of this job will result in considering upstream build as self($JOB_NAME) See https://issues.jenkins.io/browse/JENKINS-61590 for bug Either trigger from expected upstream job or run a new build */ env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ? currentBuild.upstreamBuilds[0].fullProjectName : env.DEFAULT_BUILD_JOB_NAME } } } stage('detect docker image + args') { agent { docker { label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host' image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028' registryUrl 'https://public.ecr.aws/' alwaysPull true } } steps { script { DOCKER_AGENT = detectTestDockerAgent() } } } stage('bwc-test') { agent { docker { label AGENT_LABEL image DOCKER_AGENT.image args DOCKER_AGENT.args registryUrl 'https://public.ecr.aws/' alwaysPull true } } steps { script { def buildManifestObj = downloadBuildManifest( url: BUILD_MANIFEST_URL, path: BUILD_MANIFEST ) String buildId = buildManifestObj.getArtifactBuildId() env.BUILD_ID = buildId echo "BUILD_MANIFEST: ${BUILD_MANIFEST}" echo "BUILD_ID: ${BUILD_ID}" runBwcTestScript( jobName: BUILD_JOB_NAME, buildManifest: BUILD_MANIFEST, testManifest: "manifests/${TEST_MANIFEST}", buildId: BUILD_ID ) } } post { always { script { uploadTestResults( buildManifestFileName: BUILD_MANIFEST, jobName: JOB_NAME ) } postCleanup() } } } } post { success { node(AGENT_LABEL) { script { def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) publishNotification( icon: ':white_check_mark:', message: 'BWC Tests Successful', extra: stashed, credentialsId: 'jenkins-integ-test-webhook', manifest: TEST_MANIFEST, ) postCleanup() } } } failure { node(AGENT_LABEL) { script { def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) publishNotification( icon: ':warning:', message: 'Failed BWC Tests', extra: stashed, credentialsId: 'jenkins-integ-test-webhook', manifest: TEST_MANIFEST, ) postCleanup() } } } } }