github.com/verrazzano/verrazzano@v1.7.0/release/builds/JenkinsfilePostReleaseValidation (about)

     1  // Copyright (c) 2023, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  pipeline {
     5      options {
     6          skipDefaultCheckout true
     7          timestamps ()
     8      }
     9  
    10      agent {
    11         docker {
    12              image "${RELEASE_RUNNER_IMAGE}"
    13              args "${RELEASE_RUNNER_DOCKER_ARGS}"
    14              registryUrl "${RUNNER_DOCKER_REGISTRY_URL}"
    15              registryCredentialsId 'ocir-pull-and-push-account'
    16              label "internal"
    17          }
    18      }
    19      parameters {
    20          string (description: 'The release version (major.minor.patch format, e.g. 1.0.1)', name: 'RELEASE_VERSION', defaultValue: 'NONE', trim: true)
    21          string name: 'IMAGES_OBJECT_STORE_FILE', description: 'The object store file from which to get the list of images to be published to OCR, format e.g. release-1.4/verrazzano_1.4.2-images.txt', defaultValue: 'NONE'
    22          string (description: 'The full git commit hash from the source build', name: 'GIT_COMMIT_TO_USE', defaultValue: 'NONE', trim: true )
    23      }
    24  
    25      environment {
    26          OCR_CREDS = credentials('ocr-credentials-for-release')
    27          OCR_ADMIN_CREDS = credentials('ocr-credentials-for-release')
    28          GHCR_CREDS = credentials('github-packages-credentials-rw')
    29  
    30          NETRC_FILE = credentials('netrc')
    31          DOCKER_REPO = 'container-registry.oracle.com'
    32          RELEASE_VERSION = "${params.RELEASE_VERSION}"
    33      }
    34  
    35      stages {
    36          stage('Clean workspace and checkout') {
    37              steps {
    38                  sh """
    39                      echo "${NODE_LABELS}"
    40                  """
    41                  script {
    42                      if (params.GIT_COMMIT_TO_USE == "NONE") {
    43                          echo "Specific GIT commit was not specified, use current head"
    44                          def scmInfo = checkout scm
    45                          env.GIT_COMMIT = scmInfo.GIT_COMMIT
    46                          env.GIT_BRANCH = scmInfo.GIT_BRANCH
    47                      } else {
    48                          echo "SCM checkout of ${params.GIT_COMMIT_TO_USE}"
    49                          def scmInfo = checkout([
    50                              $class: 'GitSCM',
    51                              branches: [[name: params.GIT_COMMIT_TO_USE]],
    52                              doGenerateSubmoduleConfigurations: false,
    53                              extensions: [],
    54                              submoduleCfg: [],
    55                              userRemoteConfigs: [[url: env.SCM_VERRAZZANO_GIT_URL]]])
    56                          env.GIT_COMMIT = scmInfo.GIT_COMMIT
    57                          env.GIT_BRANCH = scmInfo.GIT_BRANCH
    58                          // If the commit we were handed is not what the SCM says we are using, fail
    59                          if (!env.GIT_COMMIT.equals(params.GIT_COMMIT_TO_USE)) {
    60                              echo "SCM didn't checkout the commit we expected. Expected: ${params.GIT_COMMIT_TO_USE}, Found: ${scmInfo.GIT_COMMIT}"
    61                              exit 1
    62                          }
    63                      }
    64                      echo "SCM checkout of ${env.GIT_BRANCH} at ${env.GIT_COMMIT}"
    65                  }
    66                  sh """
    67                      cp -f "${NETRC_FILE}" $HOME/.netrc
    68                      chmod 600 $HOME/.netrc
    69                  """
    70  
    71                  script {
    72                      def props = readProperties file: '.verrazzano-development-version'
    73                      VERRAZZANO_DEV_VERSION = props['verrazzano-development-version']
    74                      TIMESTAMP = sh(returnStdout: true, script: "date +%Y%m%d%H%M%S").trim()
    75                      SHORT_COMMIT_HASH = sh(returnStdout: true, script: "git rev-parse --short=8 HEAD").trim()
    76                  }
    77              }
    78          }
    79  
    80          stage('Get Images from Object Storage') {
    81              environment {
    82                  OCI_OS_NAMESPACE = credentials('oci-os-namespace')
    83                  OCI_OS_BUCKET="verrazzano-builds"
    84                  OCI_CLI_AUTH="api_key"
    85                  OCI_CLI_TENANCY = credentials('oci-tenancy')
    86                  OCI_CLI_USER = credentials('oci-user-ocid')
    87                  OCI_CLI_FINGERPRINT = credentials('oci-api-key-fingerprint')
    88                  OCI_CLI_KEY_FILE = credentials('oci-api-key')
    89                  OCI_CLI_REGION = "us-phoenix-1"
    90                  OCI_REGION = "us-phoenix-1"
    91              }
    92              steps {
    93                   script {                
    94                      println("Downloading image list from object storage")
    95                      sh "oci --region ${OCI_REGION} os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_BUCKET} --name ${IMAGES_OBJECT_STORE_FILE} --file verrazzano_images.txt"
    96                  }
    97                }
    98              }
    99          stage('Compare Images from Object storage to be Published') {
   100              steps {
   101                  script {
   102                      sh "${WORKSPACE}/release/scripts/validate_ocr_images.sh"
   103                  }
   104              }
   105          }
   106          stage('Verify Github artifacts') {
   107              steps {
   108                  script {
   109                      sh "${WORKSPACE}/release/scripts/verify_github_release.sh ${RELEASE_VERSION}"
   110                  }
   111              }
   112          }
   113          
   114      }
   115  
   116  }
   117