github.com/verrazzano/verrazzano@v1.7.1/ci/scripts/build_distribution.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Copyright (c) 2021, 2023, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  
     7  # Normally master and release-* branches are the only ones doing this, but when we need to test out pipeline changes we can make use
     8  # as well
     9  
    10  if [ -z "$1" ]; then
    11    echo "GIT commit must be specified"
    12    exit 1
    13  fi
    14  GIT_COMMIT_USED="$1"
    15  
    16  if [ -z "$2" ]; then
    17    echo "Short commit hash must be specified"
    18    exit 1
    19  fi
    20  SHORT_COMMIT_HASH_ENV="$2"
    21  
    22  if [ -z "$3" ]; then
    23    echo "The Verrazzano development version must be specified"
    24    exit 1
    25  fi
    26  DEVELOPENT_VERSION="$3"
    27  
    28  if [ -z "$JENKINS_URL" ] || [ -z "$WORKSPACE" ] || [ -z "$OCI_OS_NAMESPACE" ] || [ -z "$OCI_OS_BUCKET" ] || [ -z "$OCI_OS_COMMIT_BUCKET" ] || [ -z "$CLEAN_BRANCH_NAME" ] || [ -z "$BRANCH_NAME" ]; then
    29    echo "This script must only be called from Jenkins and requires a number of environment variables are set"
    30    exit 1
    31  fi
    32  
    33  # We originally handled only "master" here. "master" and "release-*" branches do not have "/" in them, however we do have
    34  # those in feature branches. This causes problems in some situations, so we have 2 variants for the branch names being used here:
    35  #      BRANCH_NAME may be a path with /
    36  #      CLEAN_BRANCH_NAME has the / replaced with %2F so it is not treated as a path
    37  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/operator.yaml --file operator.yaml
    38  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/generated-verrazzano-bom.json --file generated-verrazzano-bom.json
    39  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-linux-amd64.tar.gz --file vz-linux-amd64.tar.gz
    40  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-linux-amd64.tar.gz.sha256 --file vz-linux-amd64.tar.gz.sha256
    41  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-linux-arm64.tar.gz --file vz-linux-arm64.tar.gz
    42  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-linux-arm64.tar.gz.sha256 --file vz-linux-arm64.tar.gz.sha256
    43  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-darwin-amd64.tar.gz --file vz-darwin-amd64.tar.gz
    44  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-darwin-amd64.tar.gz.sha256 --file vz-darwin-amd64.tar.gz.sha256
    45  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-darwin-arm64.tar.gz --file vz-darwin-arm64.tar.gz
    46  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/vz-darwin-arm64.tar.gz.sha256 --file vz-darwin-arm64.tar.gz.sha256
    47  
    48  # Generate a Verrazzano full Zip for private registry testing
    49  
    50  # Get the latest stable generated BOM file
    51  local_bom=${WORKSPACE}/verrazzano-bom.json
    52  last_ocir_pushed_bom=${WORKSPACE}/last-ocir-pushed-verrazzano-bom.json
    53  mkdir -p $(dirname ${local_bom}) || true
    54  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${BRANCH_NAME}/${SHORT_COMMIT_HASH_ENV}/generated-verrazzano-bom.json --file ${local_bom}
    55  # NOTE: The first time we run through for a branch we do not have a last-ocir-pushed-verrazzano-bom.bom present yet in object storage (there is no previous run), so we ignore if it fails to find one here
    56  oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_BUCKET} --name ${CLEAN_BRANCH_NAME}-last-clean-periodic-test/last-ocir-pushed-verrazzano-bom.json --file ${last_ocir_pushed_bom} || true
    57  
    58  # Note: We have Verrazzano images tar files locally under ${WORKSPACE}/tar-files
    59  # Move them to a new directory (rather than changing the vz-registry-image-helper.sh) and use the new directory from here onwards in the periodic job
    60  # The new directory is defined in the Jenkins script as an environment variable VERRAZZANO_IMAGES_DIRECTORY
    61  #
    62  echo "Creating Verrazzano Release Distribution bundles"
    63  cd ${WORKSPACE}
    64  ci/scripts/generate_vz_distribution.sh ${WORKSPACE} ${DEVELOPENT_VERSION} ${SHORT_COMMIT_HASH_ENV}
    65  
    66  
    67