import org.jenkinsci.plugins.pipeline.modeldefinition.Utils properties( [ parameters( [ string(name: 'BRANCH_TAG', defaultValue: 'origin/main'), booleanParam(name: 'AZURE', defaultValue: true, description: 'Make Azure Machine Image/Not?'), booleanParam(name: 'GCP', defaultValue: true, description: 'Make GCP Image/Not?'), string(name: 'H2OGPT_VERSION', defaultValue: "010", description: 'Example: for version 1.10.5 use 1105') ] ) ] ) node('linux && docker') { stage('Init') { cleanWs() currentBuild.displayName = "#${BUILD_NUMBER} - Rel:${H2OGPT_VERSION}" checkout scm sh('ls -al') } stage('Build Images') { try { docker.image('harbor.h2o.ai/opsh2oai/h2oai-packer-build:2').inside { parallel([ "GCP Ubuntu 20.04": { withCredentials([file(credentialsId: 'GCP_MARKETPLACE_SERVICE_ACCOUNT', variable: 'GCP_ACCOUNT_FILE')]) { dir('cloud/packer') { if (params.GCP) { sh("packer build \ --force \ -var 'project_id=h2o-gce' \ -var 'account_file=$GCP_ACCOUNT_FILE' \ -var 'h2ogpt_version=${H2OGPT_VERSION}' \ -var 'branch_tag=${BRANCH_TAG}' \ h2ogpt-gcp.json" ) archiveArtifacts artifacts: '*-image-info.json' }else { Utils.markStageSkippedForConditional('GCP Ubuntu 20.04') } } } }, "AZURE Ubuntu 20.04": { withCredentials([string(credentialsId: "AZURE_MARKETPLACE_CLIENT_ID", variable: "AZURE_CLIENT_ID"), string(credentialsId: "AZURE_MARKETPLACE_CLIENT_SECRET", variable: "AZURE_CLIENT_SECRET"), string(credentialsId: "AZURE_MARKETPLACE_SUBSCRIPTION_ID", variable: "AZURE_SUBSCRIPTION_ID"), string(credentialsId: "AZURE_MARKETPLACE_TENANT_ID", variable: "AZURE_TENANT_ID")]) { dir('cloud/packer') { if (params.AZURE) { sh("packer build \ --force \ -var 'client_id=$AZURE_CLIENT_ID' \ -var 'client_secret=$AZURE_CLIENT_SECRET' \ -var 'managed_image_resource_group_name=H2OIMAGES' \ -var 'subscription_id=$AZURE_SUBSCRIPTION_ID' \ -var 'tenant_id=$AZURE_TENANT_ID' \ -var 'h2ogpt_version=${H2OGPT_VERSION}' \ -var 'branch_tag=${BRANCH_TAG}' \ h2ogpt-azure.json" ) archiveArtifacts artifacts: '*-image-info.json' }else { Utils.markStageSkippedForConditional('AZURE Ubuntu 20.04') } } } }, ]) } } finally { cleanWs() } } }