diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05e59685014f25f7043642cc0ee833a7c5cbc641..9d4042f333eccd2287832dccb2fa7faff0bc1158 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,9 @@ stages: - publish_test - prod +variables: + OS_TENANT_ID: 8e35e961-f888-4622-bf7d-5fe9eb8cf563 + .build_image: stage: build image: 'gitlab-registry.cern.ch/linuxsupport/rpmci/kojicli' @@ -35,7 +38,7 @@ stages: export OS_PROJECT_NAME="IT Linux Support - Images" export OS_USERNAME=${IMAGECI_USER} export OS_PASSWORD=${IMAGECI_PWD} - export OS_TENANT_ID=8e35e961-f888-4622-bf7d-5fe9eb8cf563 + export OS_TENANT_ID=${OS_TENANT_ID} export OS_AUTH_TYPE=v3fedkerb export OS_AUTH_URL=https://keystone.cern.ch/v3 export OS_IDENTITY_API_VERSION=3 @@ -55,6 +58,30 @@ stages: exit $FAIL } +# YAML Anchor for after_scripts. It needs to retrieve details again as after_script runs in a different shell. Watch out for char escaping +# after_script script must be an array of commands, cannot use code blocks +.vm_details_retrieval: &vm_details_retrieval + after_script: + - echo "${IMAGECI_PWD}" | kinit ${IMAGECI_USER}@CERN.CH + - export OS_PROJECT_NAME="IT Linux Support - Images" + - export OS_USERNAME=${IMAGECI_USER} + - export OS_PASSWORD=${IMAGECI_PWD} + - export OS_TENANT_ID=${OS_TENANT_ID} + - export OS_AUTH_TYPE=v3fedkerb + - export OS_AUTH_URL=https://keystone.cern.ch/v3 + - export OS_IDENTITY_API_VERSION=3 + - export OS_IDENTITY_PROVIDER=sssd + - export OS_MUTUAL_AUTH=disabled + - export OS_PROJECT_DOMAIN_ID=default + - export OS_PROTOCOL=kerberos + - export OS_REGION_NAME=cern + - export OS_VOLUME_API_VERSION=2 + - source upload.txt + - vm_name="test"-$id + - vm_id=$(openstack server show "${vm_name}" -c id --format value) + - vm_ip=$( openstack server show "${vm_id}" -c addresses --format value | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" ) + - printf "NAME $vm_name\nVM ID $vm_id\nIPv4 $vm_ip\nImage ID $id\nPlease note this VM does not wait for DNS registration.\nYou can connect as root with KRBR5 or SSH if you were added to gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access" + .upload_test_image: extends: .openstack stage: test @@ -160,12 +187,14 @@ stages: IPv4: $vm_ip Image ID: $id Please note this VM does not wait for DNS registration. - You can connect to it with KRBR5 or SSH if you were added to https://gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access + You can connect as root with KRBR5 or SSH if you were added to https://gitlab.cern.ch/linuxsupport/rpms/cern-linuxsupport-access EOF # Try to ssh for 300seconds until ready, then run test script using https://gitlab.cern.ch/linuxsupport/testing/centos_functional_tests - ssh -o 'ConnectionAttempts 300' -oStrictHostKeyChecking=no -i imageci.pem root@"${vm_ip}" "bash -s" < ./upstreamcentostests.sh - t_CheckExitStatus $? - echo "Upstream tests ran successfully" + # Merge with details printinf in after_script + <<: *vm_details_retrieval .cern_test_image: extends: .openstack @@ -192,6 +221,8 @@ stages: # We need to pass our CI service account for retrieving a valid KRBR5 ticket - ssh -o 'ConnectionAttempts 60' -oStrictHostKeyChecking=no -i imageci.pem root@"${vm_ip}" "IMAGECI_USER='$IMAGECI_USER' IMAGECI_PWD='$IMAGECI_PWD' exec sh" < ./cerncentostests.sh - t_CheckExitStatus $? + # Merge with details printinf in after_script + <<: *vm_details_retrieval .vm_cleanup: extends: .openstack