X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fpublic-clouds-tests%2FJenkinsfile;h=a5cf8a5b0fb192a4a61c2ca038df1e2be144cd50;hb=refs%2Ftags%2Fv15.0.0;hp=9fe04354820ec41602a217d7f584166bd6cea724;hpb=22efe2bec456db3036c7bb83ba27f602367135de;p=osm%2Fdevops.git diff --git a/jenkins/public-clouds-tests/Jenkinsfile b/jenkins/public-clouds-tests/Jenkinsfile index 9fe04354..a5cf8a5b 100644 --- a/jenkins/public-clouds-tests/Jenkinsfile +++ b/jenkins/public-clouds-tests/Jenkinsfile @@ -16,13 +16,12 @@ */ pipeline { - agent none parameters { // string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER') // Parameters to define the specific OSM version to test // --> Defaults to latest stable version of Release FOURTEEN - string(defaultValue: 'https://osm-download.etsi.org/ftp/osm-14.0-fourteen/install_osm.sh', description: 'URL to OSM installer', name: 'INSTALLER_URL') + string(defaultValue: 'https://osm-download.etsi.org/ftp/osm-15.0-fifteen/install_osm.sh', description: 'URL to OSM installer', name: 'INSTALLER_URL') string(defaultValue: 'testing-daily', description: 'Release for OSM binaries (REPO_BASE)', name: 'REPO_BASE') string(defaultValue: 'testing-daily', description: 'OSM docker tag (DOCKER_TAG)', name: 'DOCKER_TAG') string(defaultValue: 'testing', description: 'Repository name for OSM packages (REPO_NAME)', name: 'REPO_NAME') @@ -36,8 +35,6 @@ pipeline { string(defaultValue: '', description: 'Jenkins credential containing SSH public key used in VMs', name: 'SSH_PUBLIC_KEY') // Parameter to set the target environment - // string(defaultValue: 'azure-etsi-environment', description: 'Defines the VIM target', name: 'VIM_TARGET_ENVIRONMENT') - // string(defaultValue: 'azure/azure.rc', description: 'Cloud config environment file', name: 'CLOUD_ENV_FILE') // Parameter to set the name of secret in Jenkins for Azure JSON credentials string(defaultValue: 'azure-credentials', description: 'Jenkins secret that contains Azure JSON credentials', name: 'AZURE_CREDENTIALS') // File format (take care of brackets in clientId): @@ -107,114 +104,112 @@ pipeline { OSM_VIM_MULTIPLIER_TIMEOUT = '4.0' */ } + agent { + docker { + label 'osm4' + image "${params.TEST_IMAGE}:${params.TEST_TAG}" + args "-u root:root --entrypoint=''" + } + } stages { - stage('E2E TESTS') { - agent { - docker { - image "${params.TEST_IMAGE}:${params.TEST_TAG}" - args "-u root:root --entrypoint=''" - } - } - stages { - stage('Set environment') { - steps { - script { - if (params.SSH_PUBLIC_KEY == '') { - // Gererate SSH private and public keys - sh "mkdir -m 700 ~/.ssh" - sh "ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''" - } - else { - // SSH private and public keys from Jenkins credentials - sh "mkdir -m 700 ~/.ssh" - withCredentials([file(credentialsId: "${params.SSH_PRIVATE_KEY}", variable: 'SSHPATH')]) { - sh "cp ${SSHPATH} ~/.ssh/id_rsa" - } - withCredentials([file(credentialsId: "${params.SSH_PUBLIC_KEY}", variable: 'SSHPATH')]) { - sh "cp ${SSHPATH} ~/.ssh/id_rsa.pub" - } - sh "chmod 400 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub" - } - // This file is used by some Robot test (BASIC12) - sh "cp ~/.ssh/id_rsa ~/osm_id_rsa" + stage('Set environment') { + steps { + script { + if (params.SSH_PUBLIC_KEY == '') { + // Gererate SSH private and public keys + sh "mkdir -m 700 ~/.ssh" + sh "ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''" + } + else { + // SSH private and public keys from Jenkins credentials + sh "mkdir -m 700 ~/.ssh" + withCredentials([file(credentialsId: "${params.SSH_PRIVATE_KEY}", variable: 'SSHPATH')]) { + sh "cp ${SSHPATH} ~/.ssh/id_rsa" } - // Azure credentials - withCredentials([file(credentialsId: "${params.AZURE_CREDENTIALS}", variable: 'PATH')]) { - sh "cp ${PATH} ~/azure-creds.json" - sh """ - set +x; \ - AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \ - AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \ - AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \ - az login --service-principal --username \$AZURE_CLIENT_ID --password \$AZURE_SECRET --tenant \$AZURE_TENANT - """ - sh "az vm list -o table" + withCredentials([file(credentialsId: "${params.SSH_PUBLIC_KEY}", variable: 'SSHPATH')]) { + sh "cp ${SSHPATH} ~/.ssh/id_rsa.pub" } + sh "chmod 400 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub" } + // This file is used by some Robot test (BASIC12) + sh "cp ~/.ssh/id_rsa ~/osm_id_rsa" + sh "echo Reading credential ${params.AZURE_CREDENTIALS}" } - stage('Create k8s cluster') { - steps { - sh "/robot-systest/cloud-scripts/create-k8s.sh" - sh "cat /robot-systest/results/k8s_environment.rc" - } - } - stage('Install OSM') { - steps { - sh "/robot-systest/cloud-scripts/create-osm-vm.sh" - sh "cat /robot-systest/results/osm_environment.rc" - sh ". /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/remote-install-osm.sh" - } - } - stage('Add VIM and K8s cluster to OSM') { - steps { - sh """ - . /robot-systest/results/osm_environment.rc ; \ - . /robot-systest/results/k8s_environment.rc ; \ - osm version ; \ - set +x; \ - export AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \ - export AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \ - export AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \ - export AZURE_SUBSCRIPTION_ID=\$(cat ~/azure-creds.json | jq -r .subscriptionId) ; \ - /robot-systest/cloud-scripts/add-vim-and-k8scluster.sh - """ - } - - } - stage('Run Robot tests') { - steps { - sh """ - . /robot-systest/results/osm_environment.rc ; \ - . /robot-systest/results/k8s_environment.rc ; \ - /robot-systest/run_test.sh -t ${params.ROBOT_RUN_TAG} - """ - } + // Azure credentials + withCredentials([file(credentialsId: "${params.AZURE_CREDENTIALS}", variable: 'FILE')]) { + sh "cp ${FILE} ~/azure-creds.json" + sh """ + set +x; \ + AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \ + AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \ + AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \ + az login --service-principal --username \$AZURE_CLIENT_ID --password \$AZURE_SECRET --tenant \$AZURE_TENANT + """ + sh "az vm list -o table" } } - post { - always { - echo "Retrieve container logs" - sh """ + } + stage('Create k8s cluster') { + steps { + sh "/robot-systest/cloud-scripts/create-k8s.sh" + sh "cat /robot-systest/results/k8s_environment.rc" + } + } + stage('Install OSM') { + steps { + sh "/robot-systest/cloud-scripts/create-osm-vm.sh" + sh "cat /robot-systest/results/osm_environment.rc" + sh ". /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/remote-install-osm.sh" + } + } + stage('Add VIM and K8s cluster to OSM') { + steps { + sh """ + . /robot-systest/results/osm_environment.rc ; \ + . /robot-systest/results/k8s_environment.rc ; \ + osm version ; \ + set +x; \ + export AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \ + export AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \ + export AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \ + export AZURE_SUBSCRIPTION_ID=\$(cat ~/azure-creds.json | jq -r .subscriptionId) ; \ + /robot-systest/cloud-scripts/add-vim-and-k8scluster.sh + """ + } + + } + stage('Run Robot tests') { + steps { + sh """ . /robot-systest/results/osm_environment.rc ; \ - /robot-systest/cloud-scripts/remote-extract-logs.sh + . /robot-systest/results/k8s_environment.rc ; \ + /robot-systest/run_test.sh -t ${params.ROBOT_RUN_TAG} """ + } + } + } + post { + always { + echo "Retrieve container logs" + sh """ + . /robot-systest/results/osm_environment.rc ; \ + /robot-systest/cloud-scripts/remote-extract-logs.sh + """ - echo "Save results" - sh "rm -rf results" - sh "cp -var /robot-systest/results /robot-systest/reports/* ." - archiveArtifacts artifacts: 'results/**/*', fingerprint: true + echo "Save results" + sh "rm -rf results" + sh "cp -var /robot-systest/results /robot-systest/reports/* ." + archiveArtifacts artifacts: 'results/**/*', fingerprint: true - echo "Updates the Robot dashboard in Jenkins" - robot outputPath: '.', passThreshold: "${params.ROBOT_PASS_THRESHOLD}", unstableThreshold: "${params.ROBOT_UNSTABLE_THRESHOLD}" + echo "Updates the Robot dashboard in Jenkins" + robot outputPath: '.', passThreshold: "${params.ROBOT_PASS_THRESHOLD}", unstableThreshold: "${params.ROBOT_UNSTABLE_THRESHOLD}" - echo "Destroy the K8s cluster" - sh '. /robot-systest/results/k8s_environment.rc ; /robot-systest/cloud-scripts/delete-k8s.sh' + echo "Destroy the K8s cluster" + sh '. /robot-systest/results/k8s_environment.rc ; /robot-systest/cloud-scripts/delete-k8s.sh' - echo "Destroy the OSM host" - sh '. /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/delete-osm-vm.sh' - sh "az vm list -o table" - } - } + echo "Destroy the OSM host" + sh '. /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/delete-osm-vm.sh' + sh "az vm list -o table" } } }