Skip to content

Commit

Permalink
refactor distribution build job
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Singh <[email protected]>
  • Loading branch information
rishabh6788 committed Nov 20, 2024
1 parent 248b7a2 commit b9b0953
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 69 deletions.
79 changes: 45 additions & 34 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -872,44 +872,55 @@ pipeline {
}
}
}
}
}
stage('docker build') {
when {
beforeAgent true
allOf {
expression {
params.BUILD_DOCKER != 'do_not_build_docker'
stage('docker build') {
when {
beforeAgent true
allOf {
expression {
params.BUILD_DOCKER != 'do_not_build_docker'
}
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression {
params.BUILD_DISTRIBUTION.contains('tar')
}
}
}
expression {
params.BUILD_PLATFORM.contains('linux')
options {
timeout(time: 90, unit: 'MINUTES')
}
expression {
params.BUILD_DISTRIBUTION.contains('tar')
agent {
docker {
label AGENT_LINUX_X64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
}
}
agent {
docker {
label AGENT_LINUX_X64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
echo "env.ARTIFACT_URL_LINUX_X64_TAR: ${env.ARTIFACT_URL_LINUX_X64_TAR}"
echo "env.ARTIFACT_URL_LINUX_ARM64_TAR: ${env.ARTIFACT_URL_LINUX_ARM64_TAR}"
steps {
script {
while(true) {
if (env.ARTIFACT_URL_LINUX_X64_TAR != null && env.ARTIFACT_URL_LINUX_ARM64_TAR != null) {
echo "env.ARTIFACT_URL_LINUX_X64_TAR: ${env.ARTIFACT_URL_LINUX_X64_TAR}"
echo "env.ARTIFACT_URL_LINUX_ARM64_TAR: ${env.ARTIFACT_URL_LINUX_ARM64_TAR}"

buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
buildNumber: "${BUILD_NUMBER}",
buildOption: "${BUILD_DOCKER}",
artifactUrlX64: env.ARTIFACT_URL_LINUX_X64_TAR,
artifactUrlArm64: env.ARTIFACT_URL_LINUX_ARM64_TAR
)
buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
buildNumber: "${BUILD_NUMBER}",
buildOption: "${BUILD_DOCKER}",
artifactUrlX64: env.ARTIFACT_URL_LINUX_X64_TAR,
artifactUrlArm64: env.ARTIFACT_URL_LINUX_ARM64_TAR
)
break
} else {
echo "Waiting for x64 and arm64 tar builds to complete, sleeping 120 seconds..."
sleep(time: 120, unit: 'SECONDS')
}
}
}
}
}
}
}
Expand Down
82 changes: 47 additions & 35 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ pipeline {
expression {
params.BUILD_DISTRIBUTION.contains('deb')
}

}
agent { label AGENT_LINUX_ARM64 }
stages {
Expand Down Expand Up @@ -834,41 +834,53 @@ pipeline {
}
}
}
}
}
stage('docker build') {
when {
beforeAgent true
allOf {
expression {
params.BUILD_DOCKER != 'do_not_build_docker'
stage('docker build') {
when {
beforeAgent true
allOf {
expression {
params.BUILD_DOCKER != 'do_not_build_docker'
}
expression {
params.BUILD_PLATFORM.contains('linux')
}
}
}
expression {
params.BUILD_PLATFORM.contains('linux')
options {
timeout(time: 90, unit: 'MINUTES')
}
agent {
docker {
label AGENT_LINUX_X64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
while (true){
if (env.ARTIFACT_URL_LINUX_X64_TAR != null && env.ARTIFACT_URL_LINUX_ARM64_TAR != null) {
echo "env.ARTIFACT_URL_LINUX_X64_TAR: ${env.ARTIFACT_URL_LINUX_X64_TAR}"
echo "env.ARTIFACT_URL_LINUX_ARM64_TAR: ${env.ARTIFACT_URL_LINUX_ARM64_TAR}"
buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
buildNumber: "${BUILD_NUMBER}",
buildOption: "${BUILD_DOCKER}",
artifactUrlX64: env.ARTIFACT_URL_LINUX_X64_TAR,
artifactUrlArm64: env.ARTIFACT_URL_LINUX_ARM64_TAR
)
break
} else {
echo "Waiting for x64 and arm64 tar builds to complete, sleeping 120 seconds..."
sleep(time: 120, unit: 'SECONDS')

}
}

}
}
}
}
agent {
docker {
label AGENT_LINUX_X64
image dockerAgent.image
args dockerAgent.args
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
echo "env.ARTIFACT_URL_LINUX_X64_TAR: ${env.ARTIFACT_URL_X64_TAR}"
echo "env.ARTIFACT_URL_LINUX_ARM64_TAR: ${env.ARTIFACT_URL_ARM64_TAR}"

buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
buildNumber: "${BUILD_NUMBER}",
buildOption: "${BUILD_DOCKER}",
artifactUrlX64: env.ARTIFACT_URL_LINUX_X64_TAR,
artifactUrlArm64: env.ARTIFACT_URL_LINUX_ARM64_TAR
)
}
}
}
Expand Down Expand Up @@ -896,7 +908,7 @@ pipeline {
}
postCleanup()
}

}
}
success {
Expand Down
93 changes: 93 additions & 0 deletions jenkins/opensearch/parallel-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
pipeline {
agent none

stages {
stage('Parallel Builds') {
parallel {
stage('Build Frontend') {
agent {label 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'}
steps {
script {
// Simulate frontend build
echo "Starting Frontend Build..."
sleep 30 // Simulate work
sh '''
echo "Installing npm packages..."
echo "Building frontend assets..."
echo "Running frontend tests..."
'''
}
}
post {
success {
echo "Frontend build completed successfully"
}
failure {
echo "Frontend build failed"
}
}
}

stage('Build Backend') {
agent {label 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'}
steps {
script {
// Simulate backend build
echo "Starting Backend Build..."
sleep 45 // Simulate work
sh '''
echo "Compiling backend code..."
echo "Running database migrations..."
echo "Running backend tests..."
'''
}
}
post {
success {
echo "Backend build completed successfully"
}
failure {
echo "Backend build failed"
}
}
}

stage('Run Integration Tests') {
agent {label 'Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host'}
steps {
script {
def workflowRun = org.jenkinsci.plugins.workflow.job.WorkflowRun
def flowExecution = org.jenkinsci.plugins.workflow.flow.FlowExecution

def rawBuild = currentBuild.rawBuild
if (rawBuild instanceof workflowRun) {
def exec = rawBuild.getExecution()
println "Pipeline execution: ${exec}"
}
}
}
post {
success {
echo "Integration tests completed successfully"
}
failure {
echo "Integration tests failed"
}
}
}
}
}
}

post {
always {
echo "Pipeline completed - cleaning up..."
}
success {
echo "All parallel stages completed successfully!"
}
failure {
echo "One or more stages failed!"
}
}
}

0 comments on commit b9b0953

Please sign in to comment.