Skip to content

Commit

Permalink
Revert code refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Jan 27, 2024
1 parent 97207b4 commit 60b4eb4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
77 changes: 71 additions & 6 deletions jenkins/release.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}"
Expand Down Expand Up @@ -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(' && ')),
Expand All @@ -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: <a href="${ref_url}">${ref_url}</a>"""
}
else {
println("Triggered by User/Timer: ${ref_url}")
currentBuild.description = """User/Timer: <a href="${ref_url}">${ref_url}</a>"""
}

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
}
}
}
}
}
2 changes: 1 addition & 1 deletion scripts/build-image-multi-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 60b4eb4

Please sign in to comment.