1cc1dc7a3Sopenharmony_ci#!/usr/bin/env bash 2cc1dc7a3Sopenharmony_ciARTIFACTORY_URL=eu-west-1.artifactory.aws.arm.com 3cc1dc7a3Sopenharmony_ciDOCKER_REGISTRY=mobile-studio--docker.${ARTIFACTORY_URL} 4cc1dc7a3Sopenharmony_ciIMAGE_NAME=astcenc 5cc1dc7a3Sopenharmony_ciIMAGE_VERSION=3.2.0 6cc1dc7a3Sopenharmony_ci 7cc1dc7a3Sopenharmony_ci# Check Artifactory credentials are set 8cc1dc7a3Sopenharmony_ciif [[ -z "${ARTIFACTORY_CREDENTIALS}" ]] 9cc1dc7a3Sopenharmony_cithen 10cc1dc7a3Sopenharmony_ci echo "ARTIFACTORY_CREDENTIALS not set" 11cc1dc7a3Sopenharmony_ci echo "e.g." 12cc1dc7a3Sopenharmony_ci echo " export ARTIFACTORY_CREDENTIALS=my.name@arm.com:API-KEY" 13cc1dc7a3Sopenharmony_ci exit 1 14cc1dc7a3Sopenharmony_cifi 15cc1dc7a3Sopenharmony_ci 16cc1dc7a3Sopenharmony_ciecho "Preparation" 17cc1dc7a3Sopenharmony_cirm -fr tmp 18cc1dc7a3Sopenharmony_cimkdir -p tmp 19cc1dc7a3Sopenharmony_ci 20cc1dc7a3Sopenharmony_ciecho "Get static analysis tools" 21cc1dc7a3Sopenharmony_cicurl -L --user ${ARTIFACTORY_CREDENTIALS} https://${ARTIFACTORY_URL}/artifactory/mobile-studio.tools/coverity/cov-analysis-linux64-2023.3.0.sh --output tmp/coverity_install.sh 22cc1dc7a3Sopenharmony_cicurl -L --user ${ARTIFACTORY_CREDENTIALS} https://${ARTIFACTORY_URL}/artifactory/mobile-studio.tools/coverity/license.dat --output tmp/coverity_license.dat 23cc1dc7a3Sopenharmony_ci 24cc1dc7a3Sopenharmony_ciecho "Building image" 25cc1dc7a3Sopenharmony_cidocker build --progress=plain \ 26cc1dc7a3Sopenharmony_ci -f jenkins/build.Dockerfile \ 27cc1dc7a3Sopenharmony_ci -t $IMAGE_NAME:latest \ 28cc1dc7a3Sopenharmony_ci -t $IMAGE_NAME:$IMAGE_VERSION \ 29cc1dc7a3Sopenharmony_ci -t $DOCKER_REGISTRY/$IMAGE_NAME:latest \ 30cc1dc7a3Sopenharmony_ci -t $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION \ 31cc1dc7a3Sopenharmony_ci tmp/ 32cc1dc7a3Sopenharmony_ci 33cc1dc7a3Sopenharmony_ciecho "Clean up temp files" 34cc1dc7a3Sopenharmony_cirm -rf tmp 35cc1dc7a3Sopenharmony_ci 36cc1dc7a3Sopenharmony_ciif [ "${1}" = "push" ] 37cc1dc7a3Sopenharmony_cithen 38cc1dc7a3Sopenharmony_ci echo "Pushing to $DOCKER_REGISTRY" 39cc1dc7a3Sopenharmony_ci docker login -u ${ARTIFACTORY_CREDENTIALS%:*} -p ${ARTIFACTORY_CREDENTIALS#*:} $DOCKER_REGISTRY 40cc1dc7a3Sopenharmony_ci docker push $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION 41cc1dc7a3Sopenharmony_ci # docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest 42cc1dc7a3Sopenharmony_ci echo "Clean up images" 43cc1dc7a3Sopenharmony_ci docker rmi $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_VERSION $DOCKER_REGISTRY/$IMAGE_NAME:latest $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION 44cc1dc7a3Sopenharmony_cielse 45cc1dc7a3Sopenharmony_ci echo "Build complete. To manually push to registry, run:" 46cc1dc7a3Sopenharmony_ci echo " docker login -u ${ARTIFACTORY_CREDENTIALS%:*} -p ${ARTIFACTORY_CREDENTIALS#*:} $DOCKER_REGISTRY" 47cc1dc7a3Sopenharmony_ci echo " docker push \"$DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION\"" 48cc1dc7a3Sopenharmony_ci # echo " docker push \"$DOCKER_REGISTRY/$IMAGE_NAME:latest\"" 49cc1dc7a3Sopenharmony_cifi 50cc1dc7a3Sopenharmony_ci 51cc1dc7a3Sopenharmony_ciecho "Script Completed" 52