Skip to content

Commit

Permalink
Add changes
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Oct 10, 2023
1 parent cec69d0 commit e1873bb
Showing 1 changed file with 93 additions and 13 deletions.
106 changes: 93 additions & 13 deletions jenkins/validate-artifacts/validate-artifacts.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ lib = library(identifier: '[email protected]', retriever: modernSCM([
]))

def docker_images = [
"tar": "opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v4",
"rpm": "opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v3",
"yum": "opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v3",
"tar": "opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2",
"rpm": "opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v1",
"yum": "opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v1",
]

def docker_args = [
"tar": "-u 1000",
"rpm": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host",
"yum": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host",
"rpm": "--entrypoint=/usr/sbin/init -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro",
"yum": "--entrypoint=/usr/sbin/init -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro",
]

def agent_nodes_docker = [
"x64": "Jenkins-Agent-AL2023-X64-C54xlarge-Single-Host",
"arm64": "Jenkins-Agent-AL2023-Arm64-C6g4xlarge-Single-Host",
"x64": "Jenkins-Agent-AL2-X64-C54xlarge-Single-Host",
"arm64": "Jenkins-Agent-AL2-Arm64-C6g4xlarge-Single-Host",
]

def agent_nodes = [
"x64": "Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host",
"arm64": "Jenkins-Agent-AL2023-Arm64-C6g4xlarge-Docker-Host",
"x64": "Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host",
"arm64": "Jenkins-Agent-AL2-Arm64-C6g4xlarge-Docker-Host",
]

pipeline {
Expand All @@ -36,6 +36,16 @@ pipeline {
description: 'Enter the OpenSearch and OpenSearch Dashboards version that needs to be validated',
trim: true
)
string(
name: 'OPENSEARCH_ARTIFACT_URL',
description: 'Enter url link of the OpenSearch artifact',
trim: true
)
string(
name: 'OPENSEARCH_DASHBOARDS_ARTIFACT_URL',
description: 'Enter url link of the OpenSearch artifact',
trim: true
)
string(
name: 'DISTRIBUTION',
description: 'Enter the distribution type among tar, rpm, yum, docker separated by space. Defaults to "tar rpm yum docker"',
Expand Down Expand Up @@ -65,6 +75,19 @@ pipeline {
trim: true,
defaultValue: "using-staging-artifact-only"
)
string(
name: 'PROJECTS',
description: 'Enter opensearch or opensearch-dashboards',
trim: true,
defaultValue: "opensearch"
)
string(
name: 'ARTIFACT_TYPE',
description: 'Enter staging or production',
trim: true,
defaultValue: "production"
)


}

Expand All @@ -73,15 +96,30 @@ pipeline {
agent { label agent_nodes["x64"] }
steps {
script {
if (VERSION == '') {
env.url_paths = [:]

OPENSEARCH_ARTIFACT_URL ? url_paths['opensearch'] = OPENSEARCH_ARTIFACT_URL : null
OPENSEARCH_DASHBOARDS_ARTIFACT_URL ? url_paths['opensearch-dashboards'] = OPENSEARCH_DASHBOARDS_ARTIFACT_URL : null

if (OPENSEARCH_DASHBOARDS_ARTIFACT_URL && OPENSEARCH_ARTIFACT_URL == "") {
currentBuild.result = 'ABORTED'
error('VERSION cannot be empty. Please provide version of the artifacts to validate')
error("Provide OPENSEARCH_ARTIFACT_URL to validate")
}

if (VERSION == '' && url_paths) {
currentBuild.result = 'ABORTED'
error('VERSION cannot be empty. Please provide either version or url paths for the artifacts to validate')
}

if (params.DISTRIBUTION.contains('docker') && (OS_BUILD_NUMBER == '' || OSD_BUILD_NUMBER == '')) {
currentBuild.result = 'ABORTED'
error("Provide OS_BUILD_NUMBER and OSD_BUILD_NUMBER args for Docker Validation")
}

if(url_paths.isEmpty()) {
ARCHITECTURE = url_paths.values().find { it.contains("x64") } ? "x64" : "arm64"
DISTRIBUTION = url_paths.values().find { it.contains("tar.gz") } ? "tar" : (url_paths.values().find { it.contains("rpm") } ? "rpm" : "yum")
}
}
}
post {
Expand All @@ -91,8 +129,47 @@ pipeline {
}
}

stage('Validate a distribution'){
when {
expression {
params.VERSION == ''
}
}
agent {
docker {
label agent_nodes["$ARCHITECTURE"]
image docker_images["$DISTRIBUTION"]
args docker_args["$DISTRIBUTION"]
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
try {
validateArtifacts("file-path": "$url_paths")
} catch (e) {
echo "Error occurred while validating $DISTRIBUTION-$ARCHITECTURE"
throw e
} finally {
echo "Completed validation for $DISTRIBUTION-$ARCHITECTURE"
postCleanup()
}
}
}
post {
always {
postCleanup()
}
}
}

stage('Validate') {
when {
expression {
params.VERSION
}
}
agent {label agent_nodes["x64"] }
steps {
script {
Expand All @@ -115,7 +192,7 @@ pipeline {
// Using scripted pipelines to trigger dynamic parallel stages
timeout(time: 30) {
if ("${local_distribution}" == "docker"){
node(agent_nodes_docker["$local_architecture"]) {
node(agent_nodes["$local_architecture"]) {
try {
stage("${local_distribution}") {
unstash "validate-artifacts-$BUILD_NUMBER"
Expand All @@ -126,6 +203,7 @@ pipeline {
arch: "${local_architecture}",
"os-build-number": "$OS_BUILD_NUMBER",
"osd-build-number": "$OSD_BUILD_NUMBER",
projects: "$PROJECTS",
"$OPTIONAL_ARGS" : ""
)
}
Expand All @@ -148,7 +226,9 @@ pipeline {
validateArtifacts(
version: "$VERSION",
distribution: "${local_distribution}",
arch: "${local_architecture}"
arch: "${local_architecture}",
projects: "$PROJECTS",
"artifact-type": "$ARTIFACT_TYPE"
)
}
} catch (e) {
Expand Down

0 comments on commit e1873bb

Please sign in to comment.