github.com/verrazzano/verrazzano@v1.7.1/ci/no-injection/Jenkinsfile (about) 1 // Copyright (c) 2023, 2024, 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 def DOCKER_IMAGE_TAG 5 def agentLabel = env.JOB_NAME.contains('master') ? "2.0-large-phx" : "2.0-large" 6 def EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS = false 7 8 pipeline { 9 options { 10 skipDefaultCheckout true 11 timestamps () 12 } 13 14 agent { 15 docker { 16 image "${RUNNER_DOCKER_IMAGE}" 17 args "${RUNNER_DOCKER_ARGS}" 18 registryUrl "${RUNNER_DOCKER_REGISTRY_URL}" 19 registryCredentialsId 'ocir-pull-and-push-account' 20 label "${agentLabel}" 21 } 22 } 23 24 parameters { 25 choice (name: 'KUBERNETES_CLUSTER_VERSION', 26 description: 'Kubernetes Version for KinD Cluster', 27 // 1st choice is the default value 28 choices: [ "1.27", "1.26", "1.25", "1.24" ]) 29 string (name: 'GIT_COMMIT_TO_USE', 30 defaultValue: 'NONE', 31 description: 'This is the full git commit hash from the source build to be used for all jobs', 32 trim: true) 33 string (name: 'VERRAZZANO_OPERATOR_IMAGE', 34 defaultValue: 'NONE', 35 description: 'Verrazzano platform operator image name (in ghcr.io repo). If not specified, the operator.yaml from Verrazzano repo will be used to create Verrazzano platform operator', 36 trim: true) 37 choice (name: 'WILDCARD_DNS_DOMAIN', 38 description: 'This is the wildcard DNS domain', 39 // 1st choice is the default value 40 choices: [ "nip.io", "sslip.io"]) 41 choice (name: 'CRD_API_VERSION', 42 description: 'This is the API crd version.', 43 // 1st choice is the default value 44 choices: [ "v1beta1", "v1alpha1"]) 45 booleanParam (description: 'Whether to create the cluster with Calico for AT testing (defaults to true)', name: 'CREATE_CLUSTER_USE_CALICO', defaultValue: true) 46 booleanParam (description: 'Whether to dump k8s cluster on success (off by default can be useful to capture for comparing to failed cluster)', name: 'DUMP_K8S_CLUSTER_ON_SUCCESS', defaultValue: false) 47 booleanParam (name: 'RUN_COHERENCE_TESTS', description: 'Whether to run the Coherence Workload/Logging tests (defaults to true)',defaultValue: true) 48 string (name: 'CONSOLE_REPO_BRANCH', 49 defaultValue: '', 50 description: 'The branch to check out after cloning the console repository.', 51 trim: true) 52 string (name: 'TAGGED_TESTS', 53 defaultValue: '', 54 description: 'A comma separated list of build tags for tests that should be executed (e.g. unstable_test). Default:', 55 trim: true) 56 string (name: 'INCLUDED_TESTS', 57 defaultValue: '.*', 58 description: 'A regex matching any fully qualified test file that should be executed (e.g. examples/helidon/). Default: .*', 59 trim: true) 60 string (name: 'EXCLUDED_TESTS', 61 defaultValue: '_excluded_test', 62 description: 'A regex matching any fully qualified test file that should not be executed (e.g. multicluster/|_excluded_test). Default: _excluded_test', 63 trim: true) 64 booleanParam (description: 'Whether to capture full cluster snapshot on test failure', name: 'CAPTURE_FULL_CLUSTER', defaultValue: false) 65 } 66 67 environment { 68 DOCKER_PLATFORM_CI_IMAGE_NAME = 'verrazzano-platform-operator-jenkins' 69 DOCKER_PLATFORM_PUBLISH_IMAGE_NAME = 'verrazzano-platform-operator' 70 GOPATH = '/home/opc/go' 71 GO_REPO_PATH = "${GOPATH}/src/github.com/verrazzano" 72 DOCKER_CREDS = credentials('github-packages-credentials-rw') 73 DOCKER_EMAIL = credentials('github-packages-email') 74 DOCKER_REPO = 'ghcr.io' 75 DOCKER_NAMESPACE = 'verrazzano' 76 NETRC_FILE = credentials('netrc') 77 CLUSTER_NAME = 'verrazzano' 78 POST_DUMP_FAILED_FILE = "${WORKSPACE}/post_dump_failed_file.tmp" 79 TESTS_EXECUTED_FILE = "${WORKSPACE}/tests_executed_file.tmp" 80 KUBECONFIG = "${WORKSPACE}/test_kubeconfig" 81 VERRAZZANO_KUBECONFIG = "${KUBECONFIG}" 82 OCR_CREDS = credentials('ocr-pull-and-push-account') 83 OCR_REPO = 'container-registry.oracle.com' 84 IMAGE_PULL_SECRET = 'verrazzano-container-registry' 85 INSTALL_CONFIG_FILE_KIND = "./tests/e2e/config/scripts/${params.CRD_API_VERSION}/install-verrazzano-kind-no-injection.yaml" 86 INSTALL_PROFILE = "prod" 87 VZ_ENVIRONMENT_NAME = "default" 88 TEST_SCRIPTS_DIR = "${GO_REPO_PATH}/verrazzano/tests/e2e/config/scripts" 89 VERRAZZANO_OPERATOR_IMAGE="${params.VERRAZZANO_OPERATOR_IMAGE}" 90 91 WEBLOGIC_PSW = credentials('weblogic-example-domain-password') // required by WebLogic application and console ingress test 92 DATABASE_PSW = credentials('todo-mysql-password') // required by console ingress test 93 94 // Environment variables required to capture cluster snapshot and bug report on test failure 95 DUMP_KUBECONFIG="${KUBECONFIG}" 96 DUMP_COMMAND="${GO_REPO_PATH}/verrazzano/tools/scripts/k8s-dump-cluster.sh" 97 TEST_DUMP_ROOT="${WORKSPACE}/test-cluster-snapshots" 98 CAPTURE_FULL_CLUSTER="${params.CAPTURE_FULL_CLUSTER}" 99 100 // Environment variable for Verrazzano CLI executable 101 VZ_COMMAND="${GO_REPO_PATH}/vz" 102 103 VERRAZZANO_INSTALL_LOGS_DIR="${WORKSPACE}/verrazzano/platform-operator/scripts/install/build/logs" 104 VERRAZZANO_INSTALL_LOG="verrazzano-install.log" 105 106 // used for console artifact capture on failure 107 JENKINS_READ = credentials('jenkins-auditor') 108 OCI_CLI_AUTH="instance_principal" 109 OCI_OS_NAMESPACE = credentials('oci-os-namespace') 110 OCI_OS_ARTIFACT_BUCKET="build-failure-artifacts" 111 VZ_CLI_TARGZ="vz-linux-amd64.tar.gz" 112 113 // used to emit metrics 114 PROMETHEUS_CREDENTIALS = credentials('prometheus-credentials') 115 TEST_ENV_LABEL = "kind" 116 TEST_ENV = "KIND" 117 K8S_VERSION_LABEL = "${params.KUBERNETES_CLUSTER_VERSION}" 118 119 // used to generate Ginkgo test reports 120 TEST_REPORT = "test-report.xml" 121 GINKGO_REPORT_ARGS = "--junit-report=${TEST_REPORT} --keep-separate-reports=true" 122 TEST_REPORT_DIR = "${WORKSPACE}/tests/e2e" 123 } 124 125 stages { 126 stage('Clean workspace and checkout') { 127 steps { 128 sh """ 129 echo "${NODE_LABELS}" 130 """ 131 132 script { 133 EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS = getEffectiveDumpOnSuccess() 134 if (params.GIT_COMMIT_TO_USE == "NONE") { 135 echo "Specific GIT commit was not specified, use current head" 136 def scmInfo = checkout scm 137 env.GIT_COMMIT = scmInfo.GIT_COMMIT 138 env.GIT_BRANCH = scmInfo.GIT_BRANCH 139 } else { 140 echo "SCM checkout of ${params.GIT_COMMIT_TO_USE}" 141 def scmInfo = checkout([ 142 $class: 'GitSCM', 143 branches: [[name: params.GIT_COMMIT_TO_USE]], 144 doGenerateSubmoduleConfigurations: false, 145 extensions: [], 146 submoduleCfg: [], 147 userRemoteConfigs: [[url: env.SCM_VERRAZZANO_GIT_URL]]]) 148 env.GIT_COMMIT = scmInfo.GIT_COMMIT 149 env.GIT_BRANCH = scmInfo.GIT_BRANCH 150 // If the commit we were handed is not what the SCM says we are using, fail 151 if (!env.GIT_COMMIT.equals(params.GIT_COMMIT_TO_USE)) { 152 echo "SCM didn't checkout the commit we expected. Expected: ${params.GIT_COMMIT_TO_USE}, Found: ${scmInfo.GIT_COMMIT}" 153 exit 1 154 } 155 } 156 echo "SCM checkout of ${env.GIT_BRANCH} at ${env.GIT_COMMIT}" 157 } 158 159 sh """ 160 cp -f "${NETRC_FILE}" $HOME/.netrc 161 chmod 600 $HOME/.netrc 162 """ 163 164 script { 165 try { 166 sh """ 167 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 168 """ 169 } catch(error) { 170 echo "docker login failed, retrying after sleep" 171 retry(4) { 172 sleep(30) 173 sh """ 174 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 175 """ 176 } 177 } 178 } 179 sh """ 180 rm -rf ${GO_REPO_PATH}/verrazzano 181 mkdir -p ${GO_REPO_PATH}/verrazzano 182 tar cf - . | (cd ${GO_REPO_PATH}/verrazzano/ ; tar xf -) 183 """ 184 185 script { 186 def props = readProperties file: '.verrazzano-development-version' 187 VERRAZZANO_DEV_VERSION = props['verrazzano-development-version'] 188 TIMESTAMP = sh(returnStdout: true, script: "date +%Y%m%d%H%M%S").trim() 189 SHORT_COMMIT_HASH = sh(returnStdout: true, script: "git rev-parse --short=8 HEAD").trim() 190 DOCKER_IMAGE_TAG = "${VERRAZZANO_DEV_VERSION}-${TIMESTAMP}-${SHORT_COMMIT_HASH}" 191 // update the description with some meaningful info 192 setDisplayName() 193 currentBuild.description = params.KUBERNETES_CLUSTER_VERSION + " : " + SHORT_COMMIT_HASH + " : " + env.GIT_COMMIT + " : " + params.GIT_COMMIT_TO_USE 194 } 195 script { 196 sh """ 197 echo "Downloading VZ CLI from object storage" 198 oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}/${VZ_CLI_TARGZ} --file ${VZ_CLI_TARGZ} 199 tar xzf ${VZ_CLI_TARGZ} -C ${GO_REPO_PATH} 200 ${GO_REPO_PATH}/vz version 201 """ 202 } 203 } 204 } 205 206 stage('Acceptance Tests') { 207 stages { 208 stage('Prepare AT environment') { 209 environment { 210 KIND_KUBERNETES_CLUSTER_VERSION="${params.KUBERNETES_CLUSTER_VERSION}" 211 OCI_CLI_AUTH="instance_principal" 212 OCI_OS_NAMESPACE = credentials('oci-os-namespace') 213 OCI_OS_LOCATION="ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}" 214 } 215 steps { 216 sh """ 217 cd ${GO_REPO_PATH}/verrazzano 218 ci/scripts/prepare_jenkins_at_environment.sh ${params.CREATE_CLUSTER_USE_CALICO} ${params.WILDCARD_DNS_DOMAIN} 219 """ 220 } 221 post { 222 failure { 223 archiveArtifacts artifacts: "**/kind-logs/**", allowEmptyArchive: true 224 } 225 always { 226 archiveArtifacts artifacts: "acceptance-test-operator.yaml,downloaded-operator.yaml", allowEmptyArchive: true 227 } 228 } 229 } 230 231 stage('verify-install') { 232 environment { 233 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/verify-install" 234 } 235 steps { 236 runGinkgoRandomize('verify-install') 237 } 238 post { 239 always { 240 archiveArtifacts artifacts: '**/coverage.html,**/logs/*,**/test-cluster-snapshots/**', allowEmptyArchive: true 241 junit testResults: '**/*test-result.xml', allowEmptyResults: true 242 } 243 } 244 } 245 246 stage('Run Acceptance Tests Infra') { 247 parallel { 248 stage('verify-scripts') { 249 steps { 250 runGinkgoRandomize('scripts', "${KUBECONFIG}") 251 } 252 } 253 stage('verify-infra restapi') { 254 environment { 255 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/verify-infra-restapi" 256 } 257 steps { 258 runGinkgoRandomize('verify-infra/restapi') 259 } 260 } 261 stage('verify-infra oam') { 262 environment { 263 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/verify-infra-oam" 264 } 265 steps { 266 runGinkgoRandomize('verify-infra/oam') 267 } 268 } 269 stage('verify-infra vmi') { 270 environment { 271 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/verify-infra-vmi" 272 } 273 steps { 274 runGinkgoRandomize('verify-infra/vmi') 275 } 276 } 277 stage('security rbac') { 278 environment { 279 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/sec-role-based-access" 280 } 281 steps { 282 runGinkgoNoFlags('security/rbac') 283 } 284 } 285 stage('system component metrics') { 286 environment { 287 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/system-component-metrics" 288 } 289 steps { 290 runGinkgo('metrics/syscomponents') 291 } 292 } 293 stage ('console') { 294 environment { 295 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/console" 296 } 297 steps { 298 catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { 299 sh "CONSOLE_REPO_BRANCH=${params.CONSOLE_REPO_BRANCH} ${GO_REPO_PATH}/verrazzano/ci/scripts/run_console_tests.sh" 300 } 301 } 302 post { 303 failure { 304 sh "${GO_REPO_PATH}/verrazzano/ci/scripts/save_console_test_artifacts.sh" 305 } 306 } 307 } 308 } 309 post { 310 always { 311 archiveArtifacts artifacts: '**/coverage.html,**/logs/*,**/test-cluster-snapshots/**', allowEmptyArchive: true 312 junit testResults: '**/*test-result.xml', allowEmptyResults: true 313 } 314 } 315 } 316 317 stage('Run Acceptance Tests Deployments') { 318 parallel { 319 stage('opensearch-topology') { 320 steps { 321 runGinkgoRandomize('opensearch/topology') 322 } 323 } 324 // stage('istio authorization policy') { 325 // environment { 326 // DUMP_DIRECTORY="${TEST_DUMP_ROOT}/istio-authz-policy" 327 // } 328 // steps { 329 // runGinkgo('istio/authz') 330 // } 331 // } 332 // Following test is disabled for now while the test code is assessed for validity in the absence of istio side cars 333 // stage('security network policies') { 334 // environment { 335 // DUMP_DIRECTORY="${TEST_DUMP_ROOT}/netpol" 336 // } 337 // steps { 338 // script { 339 // if (params.CREATE_CLUSTER_USE_CALICO == true) { 340 // runGinkgo('security/netpol') 341 // } 342 // } 343 // } 344 // } 345 stage('deployment metrics') { 346 environment { 347 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/k8sdeploy-workload-metrics" 348 } 349 steps { 350 runGinkgo('metrics/deploymetrics') 351 } 352 } 353 stage('system logging') { 354 environment { 355 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/system-logging" 356 } 357 steps { 358 runGinkgoNoFlags('logging/system') 359 } 360 } 361 stage('examples logging helidon') { 362 environment { 363 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/examples-logging-helidon" 364 } 365 steps { 366 runGinkgo('logging/helidon') 367 } 368 } 369 stage('examples helidon') { 370 environment { 371 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/examples-helidon" 372 } 373 steps { 374 runGinkgo('examples/helidon') 375 } 376 } 377 stage('weblogic workload') { 378 environment { 379 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/weblogic-workload" 380 } 381 steps { 382 runGinkgo('workloads/weblogic') 383 } 384 } 385 stage('coherence workload') { 386 when { 387 expression {params.RUN_COHERENCE_TESTS} 388 } 389 environment { 390 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/coherence-workload" 391 } 392 steps { 393 runGinkgoNoFlags('workloads/coherence') 394 } 395 } 396 stage('examples helidon-metrics') { 397 environment { 398 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/helidonmetrics" 399 } 400 when { 401 expression {params.RUN_SLOW_TESTS == true} 402 } 403 steps { 404 runGinkgo('examples/helidonmetrics') 405 } 406 } 407 stage('Ingress & logging trait WebLogic workload') { 408 environment { 409 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/loggingtrait-weblogicworkload" 410 } 411 steps { 412 runGinkgo('loggingtrait/weblogicworkload') 413 } 414 } 415 stage('logging trait Helidon workload') { 416 environment { 417 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/loggingtrait-helidonworkload" 418 } 419 steps { 420 runGinkgo('loggingtrait/helidonworkload') 421 } 422 } 423 stage('logging trait Coherence workload') { 424 when { 425 expression {params.RUN_COHERENCE_TESTS} 426 } 427 environment { 428 DUMP_DIRECTORY="${TEST_DUMP_ROOT}/loggingtrait-coherenceworkload" 429 } 430 steps { 431 runGinkgo('loggingtrait/coherenceworkload') 432 } 433 } 434 } 435 post { 436 always { 437 archiveArtifacts artifacts: '**/coverage.html,**/logs/*,**/test-cluster-snapshots/**,**/Screenshot*.png,**/ConsoleLog*.log', allowEmptyArchive: true 438 junit testResults: '**/*test-result.xml', allowEmptyResults: true 439 } 440 } 441 } 442 443 } 444 445 post { 446 failure { 447 script { 448 if ( fileExists(env.TESTS_EXECUTED_FILE) ) { 449 dumpK8sCluster('new-kind-acceptance-tests-cluster-snapshot') 450 } 451 } 452 } 453 success { 454 script { 455 if (EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS == true && fileExists(env.TESTS_EXECUTED_FILE) ) { 456 dumpK8sCluster('new-kind-acceptance-tests-cluster-snapshot') 457 } 458 } 459 } 460 } 461 } 462 } 463 464 post { 465 always { 466 script { 467 if ( fileExists(env.TESTS_EXECUTED_FILE) ) { 468 dumpVerrazzanoSystemPods() 469 dumpCattleSystemPods() 470 dumpNginxIngressControllerLogs() 471 dumpVerrazzanoPlatformOperatorLogs() 472 dumpVerrazzanoApplicationOperatorLogs() 473 dumpOamKubernetesRuntimeLogs() 474 dumpVerrazzanoApiLogs() 475 } 476 } 477 478 sh """ 479 # Copy the generated test reports to WORKSPACE to archive them 480 mkdir -p ${TEST_REPORT_DIR} 481 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 482 find . -name "${TEST_REPORT}" | cpio -pdm ${TEST_REPORT_DIR} 483 """ 484 archiveArtifacts artifacts: "**/coverage.html,**/logs/**,**/verrazzano_images.txt,**/*full-cluster*/**,**/*bug-report*/**,**/Screenshot*.png,**/ConsoleLog*.log,**/${TEST_REPORT}", allowEmptyArchive: true 485 junit testResults: "**/${TEST_REPORT}", allowEmptyResults: true 486 deleteCluster() 487 } 488 failure { 489 sh """ 490 curl -k -u ${JENKINS_READ_USR}:${JENKINS_READ_PSW} -o ${WORKSPACE}/build-console-output.log ${BUILD_URL}consoleText 491 """ 492 archiveArtifacts artifacts: '**/build-console-output.log', allowEmptyArchive: true 493 sh """ 494 curl -k -u ${JENKINS_READ_USR}:${JENKINS_READ_PSW} -o archive.zip ${BUILD_URL}artifact/*zip*/archive.zip 495 oci --region us-phoenix-1 os object put --force --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_ARTIFACT_BUCKET} --name ${env.JOB_NAME}/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/archive.zip --file archive.zip 496 rm archive.zip 497 """ 498 } 499 cleanup { 500 deleteDir() 501 } 502 } 503 } 504 505 def runGinkgoRandomize(testSuitePath, kubeConfig = '') { 506 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 507 sh """ 508 if [ ! -z "${kubeConfig}" ]; then 509 export KUBECONFIG="${kubeConfig}" 510 fi 511 if [ -d "${testSuitePath}" ]; then 512 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 513 ginkgo -p --randomize-all -v --keep-going --no-color ${GINKGO_REPORT_ARGS} -tags="${params.TAGGED_TESTS}" --focus-file="${params.INCLUDED_TESTS}" --skip-file="${params.EXCLUDED_TESTS}" ${testSuitePath}/... -- --istioInjection="disabled" 514 fi 515 """ 516 } 517 } 518 519 def runSocksVariant(variant) { 520 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 521 sh """ 522 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 523 SOCKS_SHOP_VARIANT=${variant} ginkgo -v --keep-going --no-color ${GINKGO_REPORT_ARGS} -tags="${params.TAGGED_TESTS}" --focus-file="${params.INCLUDED_TESTS}" --skip-file="${params.EXCLUDED_TESTS}" examples/socks/... 524 """ 525 } 526 } 527 528 def runGinkgo(testSuitePath) { 529 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 530 sh """ 531 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 532 ginkgo -v -keep-going --no-color ${GINKGO_REPORT_ARGS} -tags="${params.TAGGED_TESTS}" --focus-file="${params.INCLUDED_TESTS}" --skip-file="${params.EXCLUDED_TESTS}" ${testSuitePath}/... -- --istioInjection="disabled" 533 """ 534 } 535 } 536 537 def runGinkgoNoFlags(testSuitePath) { 538 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 539 sh """ 540 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 541 ginkgo -v -keep-going --no-color ${GINKGO_REPORT_ARGS} -tags="${params.TAGGED_TESTS}" --focus-file="${params.INCLUDED_TESTS}" --skip-file="${params.EXCLUDED_TESTS}" ${testSuitePath}/... 542 """ 543 } 544 } 545 546 def dumpK8sCluster(dumpDirectory) { 547 sh """ 548 ${GO_REPO_PATH}/verrazzano/ci/scripts/capture_cluster_snapshot.sh ${dumpDirectory} 549 """ 550 } 551 552 def dumpVerrazzanoSystemPods() { 553 sh """ 554 cd ${GO_REPO_PATH}/verrazzano/platform-operator 555 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/verrazzano-system-pods.log" 556 ./scripts/install/k8s-dump-objects.sh -o pods -n verrazzano-system -m "verrazzano system pods" || echo "failed" > ${POST_DUMP_FAILED_FILE} 557 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/verrazzano-system-certs.log" 558 ./scripts/install/k8s-dump-objects.sh -o cert -n verrazzano-system -m "verrazzano system certs" || echo "failed" > ${POST_DUMP_FAILED_FILE} 559 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/verrazzano-system-osd.log" 560 ./scripts/install/k8s-dump-objects.sh -o pods -n verrazzano-system -r "vmi-system-osd-*" -m "verrazzano system opensearchdashboards log" -l -c osd || echo "failed" > ${POST_DUMP_FAILED_FILE} 561 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/verrazzano-system-es-master.log" 562 ./scripts/install/k8s-dump-objects.sh -o pods -n verrazzano-system -r "vmi-system-es-master-*" -m "verrazzano system opensearchdashboards log" -l -c es-master || echo "failed" > ${POST_DUMP_FAILED_FILE} 563 """ 564 } 565 566 def dumpCattleSystemPods() { 567 sh """ 568 cd ${GO_REPO_PATH}/verrazzano/platform-operator 569 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/cattle-system-pods.log" 570 ./scripts/install/k8s-dump-objects.sh -o pods -n cattle-system -m "cattle system pods" || echo "failed" > ${POST_DUMP_FAILED_FILE} 571 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/rancher.log" 572 ./scripts/install/k8s-dump-objects.sh -o pods -n cattle-system -r "rancher-*" -m "Rancher logs" -c rancher -l || echo "failed" > ${POST_DUMP_FAILED_FILE} 573 """ 574 } 575 576 def dumpNginxIngressControllerLogs() { 577 sh """ 578 cd ${GO_REPO_PATH}/verrazzano/platform-operator 579 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/nginx-ingress-controller.log" 580 ./scripts/install/k8s-dump-objects.sh -o pods -n ingress-nginx -r "nginx-ingress-controller-*" -m "Nginx Ingress Controller" -c controller -l || echo "failed" > ${POST_DUMP_FAILED_FILE} 581 """ 582 } 583 584 def dumpVerrazzanoPlatformOperatorLogs() { 585 sh """ 586 ## dump out verrazzano-platform-operator logs 587 mkdir -p ${WORKSPACE}/verrazzano-platform-operator/logs 588 kubectl -n verrazzano-install logs --selector=app=verrazzano-platform-operator > ${WORKSPACE}/verrazzano-platform-operator/logs/verrazzano-platform-operator-pod.log --tail -1 || echo "failed" > ${POST_DUMP_FAILED_FILE} 589 kubectl -n verrazzano-install describe pod --selector=app=verrazzano-platform-operator > ${WORKSPACE}/verrazzano-platform-operator/logs/verrazzano-platform-operator-pod.out || echo "failed" > ${POST_DUMP_FAILED_FILE} 590 echo "verrazzano-platform-operator logs dumped to verrazzano-platform-operator-pod.log" 591 echo "verrazzano-platform-operator pod description dumped to verrazzano-platform-operator-pod.out" 592 echo "------------------------------------------" 593 """ 594 } 595 596 def dumpVerrazzanoApplicationOperatorLogs() { 597 sh """ 598 ## dump out verrazzano-application-operator logs 599 mkdir -p ${WORKSPACE}/verrazzano-application-operator/logs 600 kubectl -n verrazzano-system logs --selector=app=verrazzano-application-operator > ${WORKSPACE}/verrazzano-application-operator/logs/verrazzano-application-operator-pod.log --tail -1 || echo "failed" > ${POST_DUMP_FAILED_FILE} 601 kubectl -n verrazzano-system describe pod --selector=app=verrazzano-application-operator > ${WORKSPACE}/verrazzano-application-operator/logs/verrazzano-application-operator-pod.out || echo "failed" > ${POST_DUMP_FAILED_FILE} 602 echo "verrazzano-application-operator logs dumped to verrazzano-application-operator-pod.log" 603 echo "verrazzano-application-operator pod description dumped to verrazzano-application-operator-pod.out" 604 echo "------------------------------------------" 605 """ 606 } 607 608 def dumpOamKubernetesRuntimeLogs() { 609 sh """ 610 ## dump out oam-kubernetes-runtime logs 611 mkdir -p ${WORKSPACE}/oam-kubernetes-runtime/logs 612 kubectl -n verrazzano-system logs --selector=app.kubernetes.io/instance=oam-kubernetes-runtime > ${WORKSPACE}/oam-kubernetes-runtime/logs/oam-kubernetes-runtime-pod.log --tail -1 || echo "failed" > ${POST_DUMP_FAILED_FILE} 613 kubectl -n verrazzano-system describe pod --selector=app.kubernetes.io/instance=oam-kubernetes-runtime > ${WORKSPACE}/verrazzano-application-operator/logs/oam-kubernetes-runtime-pod.out || echo "failed" > ${POST_DUMP_FAILED_FILE} 614 echo "verrazzano-application-operator logs dumped to oam-kubernetes-runtime-pod.log" 615 echo "verrazzano-application-operator pod description dumped to oam-kubernetes-runtime-pod.out" 616 echo "------------------------------------------" 617 """ 618 } 619 620 def dumpVerrazzanoApiLogs() { 621 sh """ 622 cd ${GO_REPO_PATH}/verrazzano/platform-operator 623 export DIAGNOSTIC_LOG="${VERRAZZANO_INSTALL_LOGS_DIR}/verrazzano-authproxy.log" 624 ./scripts/install/k8s-dump-objects.sh -o pods -n verrazzano-system -r "verrazzano-authproxy-*" -m "verrazzano api" -c verrazzano-authproxy -l || echo "failed" > ${POST_DUMP_FAILED_FILE} 625 """ 626 } 627 628 def getEffectiveDumpOnSuccess() { 629 def effectiveValue = params.DUMP_K8S_CLUSTER_ON_SUCCESS 630 if (FORCE_DUMP_K8S_CLUSTER_ON_SUCCESS.equals("true") && (env.BRANCH_NAME.equals("master"))) { 631 effectiveValue = true 632 echo "Forcing dump on success based on global override setting" 633 } 634 return effectiveValue 635 } 636 637 def deleteCluster() { 638 sh """ 639 cd ${GO_REPO_PATH}/verrazzano/platform-operator 640 make delete-cluster 641 if [ -f ${POST_DUMP_FAILED_FILE} ]; then 642 echo "Failures seen during dumping of artifacts, treat post as failed" 643 exit 1 644 fi 645 """ 646 } 647 648 def setDisplayName() { 649 echo "Start setDisplayName" 650 def causes = currentBuild.getBuildCauses() 651 echo "causes: " + causes.toString() 652 for (cause in causes) { 653 def causeString = cause.toString() 654 echo "current cause: " + causeString 655 if (causeString.contains("UpstreamCause") && causeString.contains("Started by upstream project")) { 656 echo "This job was caused by " + causeString 657 if (causeString.contains("verrazzano-periodic-triggered-tests")) { 658 currentBuild.displayName = env.BUILD_NUMBER + " : PERIODIC" 659 } else if (causeString.contains("verrazzano-flaky-tests")) { 660 currentBuild.displayName = env.BUILD_NUMBER + " : FLAKY" 661 } 662 } 663 } 664 echo "End setDisplayName" 665 }