Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- timeout(time: 60, unit: 'MINUTES') {{
- stage('Provision') {{
- dir('infrared') {{
- if ("${{DEPLOY_STEP}}" == 'Full') {{
- OS_PARAMS = '--medium-id 24 '
- if ("${{RHEL_VERSION}}" == 'rhel7.6') {{
- OS_PARAMS += '--os-id 51'
- }}
- if ("${{RHEL_VERSION}}" == 'rhel7.5') {{
- OS_PARAMS += '--os-id 44'
- }}
- if ("${{RHEL_VERSION}}" == 'rhel7.4') {{
- OS_PARAMS += '--os-id 35'
- }}
- sh2 """
- . $ir_venv/bin/activate
- infrared foreman -v \
- --url=https://theforeman.eng.lab.tlv.redhat.com \
- --user=rhos-qe \
- --password=qum5net \
- --host-address=$HOST \
- --host-key={private-key} \
- --role baremetal,undercloud,tester \
- ${{OS_PARAMS}}
- """, basename: 'ir-provision'
- }}
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup') {{
- HYBRID_IMAGE = ''
- if ("${{RHEL_VERSION}}" == 'rhel7.6') {{
- HYBRID_IMAGE = '{rhel_76}'
- }}
- if ("${{RHEL_VERSION}}" == 'rhel7.5') {{
- HYBRID_IMAGE = '{rhel_75}'
- }}
- if ("${{RHEL_VERSION}}" == 'rhel7.4') {{
- HYBRID_IMAGE = '{rhel_74}'
- }}
- sh2 """
- . $ir_venv/bin/activate
- if [[ '{DEPLOY_STEP}' == Virsh_Cleanup ]]; then
- infrared virsh -v \
- --topology-nodes controller:3 \
- --host-address $HOST \
- --host-key {private-key} \
- --cleanup yes
- elif [[ '{hybrid}' == True || '{DEPLOY_STEP}' == Virsh_Cleanup ]]; then
- infrared workspace cleanup ci
- infrared virsh -v \
- --topology-nodes {hybrid_topology} \
- -e override.controller.memory={controller_memory} \
- -e override.undercloud.memory={undercloud_memory} \
- -e override.controller.cpu={controller_cpu} \
- -e override.undercloud.cpu={undercloud_cpu} \
- --host-address $HOST \
- --host-key {private-key} \
- --topology-network 4_nets_3_bridges_hybrid \
- -e override.networks.net1.nic={hybrid_provision_interface} \
- -e override.networks.net1.ip_address={hybrid_provision_ip_address} \
- --host-mtu-size {hybrid_mtu} \
- --image-url ${{HYBRID_IMAGE}}
- fi
- """, basename: 'ir-provision'
- }}
- }}
- }}
- }}
- stage('Generate inventory file') {{
- dir('ansible-nfv') {{
- if ("${{DEPLOY_STEP}}" == 'Introspection' || "${{DEPLOY_STEP}}" == 'Overcloud' || "${{DEPLOY_STEP}}" == 'Tempest_or_Performance') {{
- SETUP_TYPE='baremetal'
- USER='stack'
- UNDERCLOUD_GROUPS='undercloud,tester,shade,baremetal'
- GROUPS_CONFIG="-e undercloud_groups=${{ UNDERCLOUD_GROUPS }}"
- if ('{hw-topology}' == 'hybrid') {{
- SETUP_TYPE='virt'
- USER='root'
- UNDERCLOUD_GROUPS='undercloud,tester'
- HYPERVISOR_GROUPS='shade,hypervisor'
- GROUPS_CONFIG="-e undercloud_groups=${{ UNDERCLOUD_GROUPS }} -e hypervisor_groups=${{ HYPERVISOR_GROUPS }}"
- }}
- sh2 """
- . $ir_venv/bin/activate
- ansible-playbook -v \
- playbooks/tripleo/post_install/tripleo_inventory.yml \
- -e host=$HOST \
- -e user=${{USER}} \
- -e ssh_key={private-key} \
- -e setup_type=${{SETUP_TYPE}} \
- ${{ GROUPS_CONFIG }}
- ln -sf ../../../ansible-nfv/inventory ../infrared/.workspaces/ci/hosts
- """, basename: 'ansible-nfv-generate-inventory'
- }}
- }}
- }}
- timeout(time: 30, unit: 'MINUTES') {{
- stage('Delete Overcloud (if required)') {{
- dir('ansible-nfv') {{
- if ("${{DEPLOY_STEP}}" == 'Introspection' || "${{DEPLOY_STEP}}" == 'Overcloud') {{
- sh2 """
- . $ir_venv/bin/activate
- inventory=\$(cd ../infrared && infrared workspace inventory)
- ansible-playbook -v -i \$inventory \
- playbooks/tripleo/post_install/openstack_tasks.yml \
- -t setup_os_env,overcloud_delete \
- -e setup_os_env=true \
- -e overcloud_delete=true
- """, basename: 'ansible-nfv-delete-overcloud'
- }}
- }}
- }}
- }}
- timeout(time: 60, unit: 'MINUTES') {{
- stage('Undercloud') {{
- dir('infrared') {{
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup') {{
- sh2 """
- . $ir_venv/bin/activate
- infrared tripleo-undercloud -v \
- -o install.yml \
- --config-file {template-path}/undercloud.conf \
- --version {product-version} \
- --build $BUILD \
- --images-task rpm \
- --mirror {ir_tripleo_mirror}
- """, basename: 'ir-tripleo-undercloud'
- }}
- }}
- }}
- }}
- timeout(time: 30, unit: 'MINUTES') {{
- stage('Introspection') {{
- dir('infrared') {{
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup' || "${{DEPLOY_STEP}}" == 'Introspection') {{
- sh2 """
- if [[ '{hybrid}' == True ]]; then
- INSTACKENV='--hybrid {template-path}/hybrid.json -e provison_virsh_network_name=br-ctlplane'
- else
- INSTACKENV='--instackenv-file {template-path}/instackenv.json'
- fi
- . $ir_venv/bin/activate
- infrared tripleo-overcloud -v \
- -o overcloud-install.yml \
- --deployment-files {template-path} \
- \$INSTACKENV \
- --version {product-version} \
- --introspect yes \
- --tagging no \
- --deploy no
- """, basename: 'ir-tripleo-introspection'
- }}
- }}
- }}
- }}
- stage('Tagging') {{
- dir('infrared') {{
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup' || "${{DEPLOY_STEP}}" == 'Introspection') {{
- sh2 """
- if [[ '{hybrid}' == True ]]; then
- INSTACKENV='--hybrid {template-path}/hybrid.json -e provison_virsh_network_name=br-ctlplane'
- else
- INSTACKENV='--instackenv-file {template-path}/instackenv.json'
- fi
- . $ir_venv/bin/activate
- infrared tripleo-overcloud -v \
- -o overcloud-install.yml \
- --deployment-files {template-path} \
- \$INSTACKENV \
- --tagging yes \
- --deploy no \
- --introspect no
- """, basename: 'ir-tripleo-tagging'
- }}
- }}
- }}
- timeout(time: 120, unit: 'MINUTES') {{
- stage('Overcloud') {{
- dir('infrared') {{
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup' || "${{DEPLOY_STEP}}" == 'Introspection' || "${{DEPLOY_STEP}}" == 'Overcloud') {{
- sh2 """
- if [[ '{hybrid}' == True ]]; then
- INSTACKENV='--hybrid {template-path}/hybrid.json -e provison_virsh_network_name=br-ctlplane'
- else
- INSTACKENV='--instackenv-file {template-path}/instackenv.json'
- fi
- . $ir_venv/bin/activate
- infrared tripleo-overcloud -v \
- -o overcloud-install.yml \
- --version {product-version} \
- --containers {containers} \
- --deployment-files {template-path} \
- --overcloud-script {template-path}/overcloud_deploy.sh \
- \$INSTACKENV \
- --introspect no \
- --tagging no \
- --deploy yes
- """, basename: 'ir-tripleo-overcloud'
- }}
- }}
- }}
- }}
- timeout(time: 120, unit: 'MINUTES') {{
- stage('Tempest_or_Performance') {{
- dir('ansible-nfv') {{
- if ("${{DEPLOY_STEP}}" == 'Full' || "${{DEPLOY_STEP}}" == 'Virsh_Cleanup' || "${{DEPLOY_STEP}}" == 'Introspection' || "${{DEPLOY_STEP}}" == 'Overcloud' || "${{DEPLOY_STEP}}" == 'Tempest_or_Performance') {{
- sh2 """
- . $ir_venv/bin/activate
- if [[ '{run-test}' == 'tempest' ]]; then
- inventory=\$(cd ../infrared && infrared workspace inventory)
- ansible-playbook -v -i \$inventory \
- playbooks/tripleo/tester/tempest.yml \
- -e @{ci-network-config} \
- -e tempest_config={ci-network-config}
- #Copying the "core_puddle_file" file to the infrared's workspace directory
- ansible undercloud-0 -v -i \$inventory \
- -m fetch -a "src=/home/stack/core_puddle_version \
- dest=$WORKSPACE/infrared/.workspaces/ci/core_puddle_version flat=yes" --become
- for file in tempest.xml tempest.log; do \
- ansible -v -i \$inventory tester --become \
- -m fetch -a "src=/home/stack/tempest/\$file \
- dest=$WORKSPACE/infrared/.workspaces/ci/tempest_results/\${{file//tempest/tempest_results}} \
- flat=yes fail_on_missing=yes"; done
- elif [[ '{run-test}' == 'performance' ]]; then
- inventory=\$(cd ../infrared && infrared workspace inventory)
- cat << EOF >> \$inventory
- moongen ansible_ssh_host=$MOONGEN ansible_ssh_user=root ansible_ssh_private_key_file={private-key}
- [moongen]
- moongen
- EOF
- ansible-playbook -v -i \$inventory \
- playbooks/tripleo/tester/{performance-play}.yml \
- -e @{ci-network-config}
- fi
- """, basename: 'nfv-tempest-or-performance'
- }}
- }}
- }}
- }}
- status = "SUCCESS"
- }} finally {{
- currentBuild.result = status
- // Creating a variable defenition of puddle version for the jump tool.
- core_puddle_file = '$WORKSPACE/infrared/.workspaces/ci/core_puddle_version'
- def puddle_version=sh(returnStdout: true, script: """ [[ -f $core_puddle_file ]] && cat $core_puddle_file || echo '' """)
- jumpStage('results', '{polarion_test_run_id}', ir_venv, puddle_version)
- dir('infrared') {{
- sh2 """
- . $ir_venv/bin/activate
- infrared workspace export -f workspace
- ANSIBLE_FORCE_COLOR=false \
- infrared collect-logs -v --gzip yes --dest-dir=$WORKSPACE/infrared &> collect.log
- rm -rf $ir_venv
- """, basename: 'ir-collect'
- archiveArtifacts allowEmptyArchive: true, artifacts: 'ansible.cfg, *.yml, pip*, collect.log, .workspaces/**, workspace.tgz, *.tar.gz'
- junit allowEmptyResults: true, testResults: '**/tests_results.xml, logs/test_*.xml, **/ci/**/tempest*.xml, **/nosetests.xml'
- // Remove lock from host
- sh "ssh -i $HOME/.ssh/rhos-jenkins/id_rsa root@$HOST 'rm -f $lock_file'"
- }}
- if (env.SKIPMAIL == 'true') {{
- echo "Skipping email report due to SKIPMAIL parameter."
- }} else if (currentBuild.result == 'ABORTED') {{
- echo "Skipping email report as this build is ABORTED."
- }} else if ('{email_recipients}' == '') {{
- echo "Skipping email report as recipients is empty."
- }} else {{
- emailext (
- from: '{email_replyto}',
- to: '{email_recipients}',
- replyTo: '{email_replyto}',
- subject: "NFV CI Job - $currentBuild.result - $env.JOB_NAME",
- body: """The $env.JOB_NAME job finished with $currentBuild.result status.
- <p>The job could be found at: $env.BUILD_URL</p>
- <p>Full job log and tempest log are attached.</p>""",
- mimeType: 'text/html',
- attachmentsPattern: 'infrared/.workspaces/ci/tempest_results/tempest*',
- attachLog: true,
- compressLog: true
- )
- }}
- if ('{run-next-job}' != '' && status == 'SUCCESS' && "${{STOP_NEXT_JOB_RUN}}" == 'false') {{
- build job: "{run-next-job}", propagate: false, wait: false
- }}
- }}
- }}
- }}
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement