Skip to content

Commit

Permalink
AV-210720: push docker images under specific branch folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jeyapradeen-avi committed Jul 4, 2024
1 parent e3d5adb commit a3bc542
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
31 changes: 9 additions & 22 deletions amko_cicd/jenkins/ci-build/save_build_on_registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,15 @@
set -xe


source_image=$DOCKER_IMAGE_NAME:latest

AMKO_IMAGES=($DOCKER_IMAGE_NAME $DOCKER_AMKO_FEDERATOR_IMAGE_NAME $DOCKER_AMKO_SERVICE_DISCOVERY_IMAGE_NAME)
version_tag=$($WORKSPACE/hack/jenkins/get_build_version.sh $JOB_NAME $BUILD_NUMBER)

target_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/$DOCKER_IMAGE_NAME:$version_tag

sudo docker tag $source_image $target_image

sudo docker push $target_image

source_image=$DOCKER_AMKO_FEDERATOR_IMAGE_NAME:latest

target_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/$DOCKER_AMKO_FEDERATOR_IMAGE_NAME:$version_tag

sudo docker tag $source_image $target_image

sudo docker push $target_image

source_image=$DOCKER_AMKO_SERVICE_DISCOVERY_IMAGE_NAME:latest

target_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/$DOCKER_AMKO_SERVICE_DISCOVERY_IMAGE_NAME:$version_tag

sudo docker tag $source_image $target_image
echo ${AMKO_IMAGES[@]}

sudo docker push $target_image
for image in "${AMKO_IMAGES[@]}"
do
source_image=$image:latest
target_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/amko/$branch/$image:$version_tag
sudo docker tag $source_image $target_image
sudo docker push $target_image
done
6 changes: 3 additions & 3 deletions amko_cicd/jenkins/ci-build/srp/save_and_submit_srp_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ sudo /srp-tools/srp provenance declare-source git --verbose --set-key=mainsrc --
#Enable this option to create image manifest.json
export DOCKER_CLI_EXPERIMENTAL=enabled

CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko
CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko/$branch/amko
IMAGE_DIGEST=`sudo docker images $CI_REGISTRY_IMAGE --digests | grep sha256 | xargs | cut -d " " -f3`
echo $IMAGE_DIGEST
docker manifest inspect $CI_REGISTRY_PATH/amko:${build_version} --insecure > amko_manifest.json
cat amko_manifest.json
sudo /srp-tools/srp provenance add-output package.oci --set-key=amko-image --action-key=amko-build --name=${CI_REGISTRY_IMAGE} --digest=${IMAGE_DIGEST} --manifest-path $WORKSPACE/amko_manifest.json --working-dir $WORKSPACE/provenance

CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko-federator
CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko/$branch/amko-federator
IMAGE_DIGEST=`sudo docker images $CI_REGISTRY_IMAGE --digests | grep sha256 | xargs | cut -d " " -f3`
echo $IMAGE_DIGEST
docker manifest inspect $CI_REGISTRY_PATH/amko-federator:${build_version} --insecure > amko_federator_manifest.json
cat amko_federator_manifest.json
sudo /srp-tools/srp provenance add-output package.oci --set-key=amko-federator-image --action-key=amko-build --name=${CI_REGISTRY_IMAGE} --digest=${IMAGE_DIGEST} --manifest-path $WORKSPACE/amko_federator_manifest.json --working-dir $WORKSPACE/provenance

CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko-service-discovery
CI_REGISTRY_IMAGE=$CI_REGISTRY_PATH/amko/$branch/amko-service-discovery
IMAGE_DIGEST=`sudo docker images $CI_REGISTRY_IMAGE --digests | grep sha256 | xargs | cut -d " " -f3`
echo $IMAGE_DIGEST
docker manifest inspect $CI_REGISTRY_PATH/amko-service-discovery:${build_version} --insecure > amko_service_discovery_manifest.json
Expand Down
4 changes: 2 additions & 2 deletions amko_cicd/jenkins/ci-build/sync-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

version_tag=$($WORKSPACE/hack/jenkins/get_build_version.sh $JOB_NAME $build_num)

source_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/$DOCKER_IMAGE_NAME:$version_tag
source_image=$PVT_DOCKER_REGISTRY/$PVT_DOCKER_REPOSITORY/amko/$branch/$DOCKER_IMAGE_NAME:$version_tag

sudo docker pull $source_image

Expand Down Expand Up @@ -39,7 +39,7 @@ fi

for registry in "${registries[@]}"
do
target_image="$registry/$PVT_DOCKER_REPOSITORY/$DOCKER_IMAGE_NAME:$version_tag"
target_image="$registry/$PVT_DOCKER_REPOSITORY/amko/$branch/$DOCKER_IMAGE_NAME:$version_tag"
echo "Tagging and pushing to registry: $registry"
sudo docker tag $source_image $target_image
sudo docker push $target_image
Expand Down

0 comments on commit a3bc542

Please sign in to comment.