Kailash Khalasi | e43352e | 2018-06-15 18:46:40 -0700 | [diff] [blame] | 1 | /* mcord-in-a-box 6.0 pipeline build and test*/ |
| 2 | |
| 3 | pipeline { |
| 4 | |
| 5 | /* no label, executor is determined by JJB */ |
| 6 | agent { |
| 7 | label "${params.executorNode}" |
| 8 | } |
| 9 | |
| 10 | stages { |
| 11 | |
| 12 | stage ('Checkout Automation-Tools Repo') { |
| 13 | steps { |
| 14 | sh ''' |
| 15 | pushd $WORKSPACE |
| 16 | git clone https://gerrit.opencord.org/automation-tools |
| 17 | popd |
| 18 | ''' |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | stage ('Install MCORD') { |
| 23 | steps { |
| 24 | sh ''' |
| 25 | pushd $WORKSPACE |
| 26 | ./automation-tools/mcord/mcord-in-a-box.sh |
| 27 | popd |
| 28 | ''' |
| 29 | } |
| 30 | } |
Kailash Khalasi | b3445fa | 2018-06-21 17:05:56 -0700 | [diff] [blame] | 31 | stage ('Configure K8 Compute Node DNS') { |
| 32 | steps { |
| 33 | sh ''' |
| 34 | pushd $WORKSPACE |
| 35 | HOSTNAME=\$(cat /etc/hostname) |
| 36 | IPADDRESS=\$(ip route get 8.8.8.8 | head -1 | cut -d' ' -f8) |
| 37 | cat <<EOF > /tmp/\$HOSTNAME-dns.yaml |
| 38 | kind: Service |
| 39 | apiVersion: v1 |
| 40 | metadata: |
| 41 | name: \$HOSTNAME |
| 42 | namespace: default |
| 43 | spec: |
| 44 | type: ExternalName |
| 45 | externalName: \$IPADDRESS |
| 46 | EOF |
| 47 | popd |
| 48 | kubectl create -f /tmp/\$HOSTNAME-dns.yaml |
| 49 | ''' |
| 50 | } |
| 51 | } |
Kailash Khalasi | e43352e | 2018-06-15 18:46:40 -0700 | [diff] [blame] | 52 | |
| 53 | stage ('Test MCORD') { |
| 54 | steps { |
| 55 | sh ''' |
| 56 | pushd $WORKSPACE |
| 57 | git clone https://gerrit.opencord.org/mcord |
| 58 | cd mcord/test |
Kailash Khalasi | b3445fa | 2018-06-21 17:05:56 -0700 | [diff] [blame] | 59 | ansible-playbook -i localhost, -c local mcord-cavium-test-playbook.yml |
Kailash Khalasi | e43352e | 2018-06-15 18:46:40 -0700 | [diff] [blame] | 60 | popd |
| 61 | ''' |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | post { |
| 67 | always { |
| 68 | sh ''' |
| 69 | pushd $WORKSPACE |
| 70 | kubectl get pods --all-namespaces |
| 71 | if [ -x "/usr/bin/helm" ]; then |
| 72 | helm list |
| 73 | helm delete --purge xos-core |
| 74 | helm delete --purge mcord |
| 75 | helm delete --purge base-openstack |
Kailash Khalasi | b3445fa | 2018-06-21 17:05:56 -0700 | [diff] [blame] | 76 | helm delete --purge onos-cord |
| 77 | |
| 78 | for NS in openstack ceph nfs libvirt; do |
| 79 | helm ls --namespace $NS --short | xargs -r -L1 -P2 helm delete --purge |
| 80 | done |
| 81 | |
| 82 | # delete any helm chart left |
| 83 | helm ls --short | xargs -r -L1 -P2 helm delete --purge || true |
| 84 | |
| 85 | #delete all kubectl pods |
| 86 | kubectl delete pods --all |
| 87 | |
| 88 | sudo docker ps -aq | xargs -r -L1 -P16 sudo docker rm -f |
| 89 | |
| 90 | sudo rm -rf /var/lib/openstack-helm/* |
| 91 | |
| 92 | # NOTE(portdirect): These directories are used by nova and libvirt |
| 93 | sudo rm -rf /var/lib/nova/* |
| 94 | sudo rm -rf /var/lib/libvirt/* |
| 95 | sudo rm -rf /etc/libvirt/qemu/* |
| 96 | |
| 97 | #remove all docker images |
| 98 | sudo docker rmi $(sudo docker images -q) || true |
| 99 | |
Kailash Khalasi | e43352e | 2018-06-15 18:46:40 -0700 | [diff] [blame] | 100 | fi |
Kailash Khalasi | b3445fa | 2018-06-21 17:05:56 -0700 | [diff] [blame] | 101 | kubectl get pods || true |
| 102 | helm ls || true |
| 103 | sudo rm -rf $WORKSPACE/* |
Kailash Khalasi | e43352e | 2018-06-15 18:46:40 -0700 | [diff] [blame] | 104 | popd |
| 105 | ''' |
| 106 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 107 | } |
| 108 | } |
| 109 | } |