Skip to content

Commit

Permalink
Add sidecar to jenkins build
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Woehrl <[email protected]>
  • Loading branch information
swoehrl-mw committed Jan 23, 2025
1 parent 0b61e6d commit 1e33530
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
51 changes: 51 additions & 0 deletions jenkins/release.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,59 @@ pipeline {
sh("git checkout ${ref_final}")

def OPERATOR_PRODUCT = "opensearch-operator"
def SIDECAR_PRODUCT = "operator-sidecar"
def OPERATOR_VERSION = ref_final.substring(1);


// First build and promote image for the sidecar
echo("${SIDECAR_PRODUCT}: ${OPERATOR_VERSION}")

// Build and push to dockerhub staging repo https://hub.docker.com/r/opensearchstaging/opensearch-operator.
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 operator-sidecar',
[
'bash',
'../scripts/build-image-multi-arch.sh',
"-v ${OPERATOR_VERSION}",
"-a 'x64,arm,arm64'",
"-f Dockerfile",
"-p ${SIDECAR_PRODUCT}"
].join(' ')
].join(' && ')),
]
}
// This is required to copy the operator to staging ECR https://gallery.ecr.aws/opensearchstaging/opensearch-operator repo as the docker-promotion job does not promote to staging ECR.
dockerCopy: {
build job: 'docker-copy',
parameters: [
string(name: 'SOURCE_IMAGE_REGISTRY', value: 'opensearchstaging'),
string(name: 'SOURCE_IMAGE', value: "${SIDECAR_PRODUCT}:${OPERATOR_VERSION}"),
string(name: 'DESTINATION_IMAGE_REGISTRY', value: 'public.ecr.aws/opensearchstaging'),
string(name: 'DESTINATION_IMAGE', value: "${SIDECAR_PRODUCT}:${OPERATOR_VERSION}")
]
}

// Promote to DockerHub Prod https://hub.docker.com/r/opensearchproject/opensearch-operator repo.
// Promote to ECR Prod https://gallery.ecr.aws/opensearchproject/opensearch-operator repo.
dockerPromotion: {
build job: 'docker-promotion',
parameters: [
string(name: 'SOURCE_IMAGES', value: "${SIDECAR_PRODUCT}:${OPERATOR_VERSION}"),
string(name: 'RELEASE_VERSION', value: "${OPERATOR_VERSION}"),
booleanParam(name: 'DOCKER_HUB_PROMOTE', value: true),
booleanParam(name: 'ECR_PROMOTE', value: true),
booleanParam(name: 'TAG_LATEST', value: true),
booleanParam(name: 'TAG_MAJOR_VERSION', value: false)
]
}

// Then build the actual operator image
echo("${OPERATOR_PRODUCT}: ${OPERATOR_VERSION}")

// Build and push to dockerhub staging repo https://hub.docker.com/r/opensearchstaging/opensearch-operator.
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-image-multi-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ else
IFS=', ' read -r -a TARBALL_ARRAY <<< "$TARBALL"
fi

if [ "$PRODUCT" != "opensearch-operator-busybox" ] && [ "$PRODUCT" != "opensearch-operator" ]
if [ "$PRODUCT" != "opensearch-operator-busybox" ] && [ "$PRODUCT" != "opensearch-operator" ] && [ "$PRODUCT" != "operator-sidecar" ]
then
echo "Enter either 'opensearch-operator' or 'opensearch-operator-busybox' as product name for -p parameter"
echo "Enter either 'opensearch-operator' or 'opensearch-operator-busybox' or 'operator-sidecar' as product name for -p parameter"
exit 1
else
PRODUCT_ALT=`echo $PRODUCT | sed 's@-@_@g'`
Expand Down

0 comments on commit 1e33530

Please sign in to comment.