Skip to content

Commit

Permalink
Jenkinsfile change for Branching
Browse files Browse the repository at this point in the history
Signed-off-by: prudhvigodithi <pgodithi@amazon.com>
  • Loading branch information
prudhvigodithi committed Sep 7, 2022
1 parent e1c5883 commit da67b1a
Show file tree
Hide file tree
Showing 20 changed files with 335 additions and 50 deletions.
14 changes: 4 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ sourceSets {
srcDirs = ['tests/jenkins']
}
}

jobs {
groovy {
srcDirs 'src/jenkins/jobs'
compileClasspath += main.compileClasspath
}

compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}

sharedLibrary {
Expand Down Expand Up @@ -127,3 +117,7 @@ jacocoTestReport {
xml.required = true
}
}

tasks.test {
maxParallelForks = Runtime.getRuntime().availableProcessors()
}
29 changes: 27 additions & 2 deletions jenkins/opensearch-dashboards/bwc-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))
pipeline {
options {
timeout(time: 3, unit: 'HOURS')
skipDefaultCheckout()
}
agent none
environment {
BUILD_MANIFEST = "build-manifest.yml"
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards"
BUILD_REPO = 'https://github.com/opensearch-project/opensearch-build.git'
}
parameters {
string(
Expand All @@ -20,20 +22,40 @@ pipeline {
description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.0.0/98/linux/x64/builds/opensearch-dashboards/manifest.yml.',
trim: true
)
string(
name: 'BUILD_BRANCH',
description: "Build repo branch to use.",
defaultValue: "main",
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('checkout the build repo') {
agent {
docker {
label AGENT_LABEL
image 'alpine:3'
alwaysPull true
}
}
steps {
git url: BUILD_REPO, branch: BUILD_BRANCH
stash(name: 'sourceRepo')
}
}
stage('verify-parameters') {
agent {
node {
label AGENT_LABEL
}
}
steps {
unstash(name: 'sourceRepo')
script {
currentBuild.description = TEST_MANIFEST
if (AGENT_LABEL == '') {
Expand Down Expand Up @@ -63,6 +85,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
DOCKER_AGENT = detectTestDockerAgent()
}
Expand All @@ -78,6 +101,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
def buildManifestObj = downloadBuildManifest(
url: BUILD_MANIFEST_URL,
Expand All @@ -99,6 +123,7 @@ pipeline {
post {
always {
script {
unstash(name: 'sourceRepo')
uploadTestResults(
buildManifestFileName: BUILD_MANIFEST,
jobName: JOB_NAME
Expand All @@ -113,6 +138,7 @@ pipeline {
post {
success {
node(AGENT_LABEL) {
unstash(name: 'sourceRepo')
script {
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
publishNotification(
Expand All @@ -122,13 +148,13 @@ pipeline {
credentialsId: 'jenkins-integ-test-webhook',
manifest: TEST_MANIFEST,
)

postCleanup()
}
}
}
failure {
node(AGENT_LABEL) {
unstash 'sourceRepo'
script {
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
publishNotification(
Expand All @@ -138,7 +164,6 @@ pipeline {
credentialsId: 'jenkins-integ-test-webhook',
manifest: TEST_MANIFEST,
)

postCleanup()
}
}
Expand Down
43 changes: 39 additions & 4 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))
pipeline {
options {
timeout(time: 4, unit: 'HOURS')
skipDefaultCheckout()
}
agent none
environment {
AGENT_X64 = 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host'
AGENT_ARM64 = 'Jenkins-Agent-AL2-Arm64-C6g4xlarge-Docker-Host'
IMAGE_RPM = 'opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-build-v2' // required for rpm to create digest sha256 correctly with rpm 4.12+
BUILD_REPO = 'https://github.com/opensearch-project/opensearch-build.git'
}
parameters {
string(
Expand Down Expand Up @@ -38,6 +40,12 @@ pipeline {
defaultValue: "bwc-test-opensearch-dashboards",
trim: true
)
string(
name: 'BUILD_BRANCH',
description: "Build repo branch to use.",
defaultValue: "main",
trim: true
)
choice(
name: 'BUILD_DOCKER',
description: 'Build docker image or not with options.',
Expand All @@ -50,6 +58,19 @@ pipeline {
)
}
stages {
stage('checkout the build repo') {
agent {
docker {
label AGENT_X64
image 'alpine:3'
alwaysPull true
}
}
steps {
git url: BUILD_REPO, branch: BUILD_BRANCH
stash(name: 'sourceRepo')
}
}
stage('detect docker image + args') {
agent {
docker {
Expand All @@ -59,6 +80,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
currentBuild.description = "$INPUT_MANIFEST"
dockerAgent = detectDockerAgent()
Expand All @@ -74,6 +96,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
buildInfoYaml(
componentName: COMPONENT_NAME,
Expand Down Expand Up @@ -101,6 +124,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
def buildManifestObj = buildAssembleUpload(
componentName: "${COMPONENT_NAME}",
Expand Down Expand Up @@ -177,14 +201,14 @@ pipeline {
}
post {
always {
unstash(name: 'sourceRepo')
script {
lib.jenkins.Messages.new(this).add(
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) +
"\n${env.ARTIFACT_URL_X64_TAR_INTEG_TEST_RESULT}" +
"\n${env.ARTIFACT_URL_X64_TAR_BWC_TEST_RESULT}"
)

postCleanup()
}
}
Expand All @@ -203,6 +227,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
buildArchive(
componentName: "${COMPONENT_NAME}",
Expand All @@ -229,6 +254,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
def buildManifestObj = archiveAssembleUpload(
componentName: "${COMPONENT_NAME}",
Expand Down Expand Up @@ -266,6 +292,7 @@ pipeline {
}
post {
always {
unstash(name: 'sourceRepo')
script {
lib.jenkins.Messages.new(this).add(
"${STAGE_NAME}",
Expand Down Expand Up @@ -293,6 +320,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
buildArchive(
componentName: "${COMPONENT_NAME}",
Expand Down Expand Up @@ -320,6 +348,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
def buildManifestObj = archiveAssembleUpload(
componentName: "${COMPONENT_NAME}",
Expand Down Expand Up @@ -396,14 +425,14 @@ pipeline {
}
post {
always {
unstash(name: 'sourceRepo')
script {
lib.jenkins.Messages.new(this).add(
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) +
"\n${env.ARTIFACT_URL_ARM64_TAR_INTEG_TEST_RESULT}" +
"\n${env.ARTIFACT_URL_ARM64_TAR_BWC_TEST_RESULT}"
)

postCleanup()
}
}
Expand All @@ -424,6 +453,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
buildArchive(
componentName: "${COMPONENT_NAME}",
Expand All @@ -450,6 +480,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
def buildManifestObj = archiveAssembleUpload(
componentName: "${COMPONENT_NAME}",
Expand Down Expand Up @@ -486,6 +517,7 @@ pipeline {
}
post {
always {
unstash(name: 'sourceRepo')
script {
lib.jenkins.Messages.new(this).add(
"${STAGE_NAME}",
Expand All @@ -512,6 +544,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
uploadIndexFile(
indexFilePath: env.INDEX_FILE_PATH
Expand All @@ -535,6 +568,7 @@ pipeline {
}
}
steps {
unstash(name: 'sourceRepo')
script {
echo "env.ARTIFACT_URL_X64_TAR: ${env.ARTIFACT_URL_X64_TAR}"
echo "env.ARTIFACT_URL_ARM64_TAR: ${env.ARTIFACT_URL_ARM64_TAR}"
Expand All @@ -553,6 +587,7 @@ pipeline {
post {
always {
node(AGENT_X64) {
unstash(name: 'sourceRepo')
script {
buildInfoYaml(
componentName: COMPONENT_NAME,
Expand All @@ -567,6 +602,7 @@ pipeline {
}
success {
node(AGENT_X64) {
unstash(name: 'sourceRepo')
script {
if (params.PUBLISH_NOTIFICATION) {
def stashed = lib.jenkins.Messages.new(this).get([
Expand All @@ -584,13 +620,13 @@ pipeline {
manifest: "${INPUT_MANIFEST}"
)
}

postCleanup()
}
}
}
failure {
node(AGENT_X64) {
unstash(name: 'sourceRepo')
script {
if (params.PUBLISH_NOTIFICATION) {
publishNotification(
Expand All @@ -600,7 +636,6 @@ pipeline {
manifest: "${INPUT_MANIFEST}"
)
}

postCleanup()
}
}
Expand Down
Loading

0 comments on commit da67b1a

Please sign in to comment.