From 60b4eb4f05acdb7b1ba7c9ae89992198db4f0af3 Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Fri, 26 Jan 2024 15:47:14 -0800 Subject: [PATCH] Revert code refactor Signed-off-by: Prudhvi Godithi --- jenkins/release.jenkinsfile | 77 ++++++++++++++++++++++++++++--- scripts/build-image-multi-arch.sh | 2 +- 2 files changed, 72 insertions(+), 7 deletions(-) diff --git a/jenkins/release.jenkinsfile b/jenkins/release.jenkinsfile index e4b6edd16..29c6be359 100644 --- a/jenkins/release.jenkinsfile +++ b/jenkins/release.jenkinsfile @@ -42,7 +42,6 @@ pipeline { causeString: 'A commit was pushed on opensearch-project/opensearch-k8s-operator repository main branch causing this workflow to run', printContributedVariables: false, printPostContent: false, - regexpFilterText: '$isTag', ) } environment { @@ -55,7 +54,6 @@ pipeline { steps { script { def ref_final = "${GIT_REFERENCE}" - println("the ref_final was : ${ref_final}") def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}" if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) { ref_final = "${ref}" @@ -89,15 +87,14 @@ pipeline { string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"), string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"), string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [ - 'id', - 'pwd', 'ls -l', + 'cd opensearch-operator', [ 'bash', - 'scripts/build-image-multi-arch.sh', + '../scripts/build-image-multi-arch.sh', "-v ${OPERATOR_VERSION}", "-a 'x64,arm,arm64'", - "-f opensearch-operator/Dockerfile-busybox", + "-f Dockerfile-busybox", "-p ${OPERATOR_PRODUCT}" ].join(' ') ].join(' && ')), @@ -121,5 +118,73 @@ pipeline { } } } + stage('OpenSearch Operator') { + steps { + script { + def ref_final = "${GIT_REFERENCE}" + def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}" + if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) { + ref_final = "${ref}" + ref_url = "${REPO_URL}/releases/tag/${ref}" + println("Triggered by GitHub: ${ref_url}") + + currentBuild.description = """GitHub: ${ref_url}""" + } + else { + println("Triggered by User/Timer: ${ref_url}") + currentBuild.description = """User/Timer: ${ref_url}""" + } + + if (ref_final == null || ref_final == '') { + currentBuild.result = 'ABORTED' + error("Missing git tag reference.") + } + + echo("Git checkout ${REPO_URL} on ${ref_final} for opensearch-operator-busybox release") + checkout scm + sh("git checkout ${ref_final}") + + def OPERATOR_PRODUCT = "opensearch-operator" + def OPERATOR_VERSION = "$ref_final" + + echo("${OPERATOR_PRODUCT}: ${OPERATOR_VERSION}") + + dockerBuild: { + build job: 'docker-build', + parameters: [ + string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"), + string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"), + string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [ + 'ls -l', + 'cd opensearch-operator', + [ + 'bash', + '../scripts/build-image-multi-arch.sh', + "-v ${OPERATOR_VERSION}", + "-a 'x64,arm,arm64'", + "-f Dockerfile", + "-p ${OPERATOR_PRODUCT}" + ].join(' ') + ].join(' && ')), + ] + } + dockerPromotion: { + build job: 'docker-promotion', + parameters: [ + string(name: 'SOURCE_IMAGES', value: '${OPERATOR_PRODUCT}:${OPERATOR_VERSION}'), + string(name: 'RELEASE_VERSION', value: "${OPERATOR_VERSION}"), + string(name: 'DOCKER_HUB_PROMOTE', value: true), + string(name: 'ECR_PROMOTE', value: true), + string(name: 'TAG_LATEST', value: true) + ] + } + } + } + post { + always { + cleanWs disableDeferredWipeout: true, deleteDirs: true + } + } + } } } diff --git a/scripts/build-image-multi-arch.sh b/scripts/build-image-multi-arch.sh index 389f12772..a38338306 100644 --- a/scripts/build-image-multi-arch.sh +++ b/scripts/build-image-multi-arch.sh @@ -135,4 +135,4 @@ docker ps | grep $BUILDER_NAME # Build multi-arch images PLATFORMS=`echo "${ARCHITECTURE_ARRAY[@]/#/linux/}" | sed 's/x64/amd64/g;s/ /,/g'` && echo PLATFORMS $PLATFORMS -docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t pgodithi/opensearchproject/$PRODUCT:${VERSION} -f $DOCKERFILE . --push +docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t opensearchstaging/$PRODUCT:${VERSION} -f $DOCKERFILE . --push