d33bdda325727db3efb2431bb4e82ed842915b59
[releng.git] / jjb / qtip / qtip-ci-jobs.yml
1 ####################################
2 # job configuration for qtip
3 ####################################
4 - project:
5     name: qtip-ci-jobs
6
7     project: 'qtip'
8
9 #--------------------------------
10 # BRANCH ANCHORS
11 #--------------------------------
12     master: &master
13         stream: master
14         branch: '{stream}'
15         gs-pathname: ''
16     brahmaputra: &brahmaputra
17         stream: brahmaputra
18         branch: 'stable/{stream}'
19         gs-pathname: '{stream}'
20 #--------------------------------
21 # POD, INSTALLER, AND BRANCH MAPPING
22 #--------------------------------
23 #        brahmaputra
24 #--------------------------------
25     pod:
26         - dell-us-testing-bm-1:
27             installer: compass
28             <<: *brahmaputra
29         - orange-pod2:
30             installer: joid
31             <<: *brahmaputra
32         - dell-us-deploying-bm3:
33             installer: fuel
34             <<: *brahmaputra
35
36 #--------------------------------
37 #        master
38 #--------------------------------
39         - juniper-pod1:
40             installer: joid
41             <<: *master
42 #      - zte-build-1:   #would be confirmed with the ZTE lab by tomorrow
43 #            installer: fuel
44 #            <<: *master
45
46 #--------------------------------
47     jobs:
48         - 'qtip-{installer}-{pod}-daily-{stream}'
49
50 ################################
51 # job templates
52 ################################
53 - job-template:
54     name: 'qtip-{installer}-{pod}-daily-{stream}'
55
56     disabled: false
57
58     parameters:
59       - project-parameter:
60           project: '{project}'
61       - '{pod}-defaults'
62       - '{installer}-defaults'
63       - string:
64           name: DEPLOY_SCENARIO
65           default: 'os-nosdn-nofeature-ha'
66
67     scm:
68        - git-scm:
69            credentials-id: '{ssh-credentials}'
70            refspec: ''
71            branch: '{branch}'
72
73     builders:
74         - 'qtip-cleanup'
75         - 'qtip-set-env'
76         - 'qtip-run-suite'
77         - 'qtip-pushtoDB'
78
79     publishers:
80         - email:
81             recipients: nauman.ahad@xflowresearch.com, mofassir.arif@xflowresearch.com, vikram@nvirters.com
82
83 ###########################
84 #biuilder macros
85 ###########################
86 - builder:
87     name: qtip-set-env
88     builders:
89         - shell: |
90             #!/bin/bash
91             echo "Qtip: Start Docker and prepare environment"
92             envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
93             suite="TEST_CASE=all"
94             docker pull opnfv/qtip:latest
95             cmd=" docker run -id -e $envs -e $suite opnfv/qtip:latest /bin/bash"
96             echo "Qtip: Running docker run command: ${cmd}"
97             ${cmd}
98             docker ps -a
99             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
100              if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then
101                 echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..."
102                 exit 1
103             fi
104 - builder:
105     name: qtip-run-suite
106     builders:
107         - shell: |
108             #!/bin/bash
109             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
110             if [[ ! -z ${container_id} ]]; then
111                 echo "The container ID is: ${container_id}"
112                 QTIP_REPO=/home/opnfv/repos/qtip
113                 docker exec -t ${container_id} $QTIP_REPO/docker/run_qtip.sh
114             else
115                 echo "Container ID not available"
116             fi
117
118 - builder:
119     name: qtip-pushtoDB
120     builders:
121         - shell: |
122             #!/bin/bash
123
124             echo "Pushing available results to DB"
125             echo "The container id is:"
126             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
127             if [[ ! -z ${container_id} ]]; then
128                 echo "The condiner ID is: ${container_id}"
129                 QTIP_REPO=/home/opnfv/repos/qtip
130                 docker exec -t ${container_id} $QTIP_REPO/docker/push_db.sh
131             else
132                 echo "Container ID not available"
133             fi
134
135 - builder:
136     name: qtip-cleanup
137     builders:
138         - shell: |
139             #!/bin/bash
140
141             echo "Cleaning up QTIP  docker containers/images..."
142             # Remove previous running containers if exist
143             if [[ ! -z $(docker ps -a | grep opnfv/qtip) ]]; then
144                 echo "Removing existing opnfv/qtip containers..."
145                 running_containers=$(docker ps | grep opnfv/qtip | awk '{print $1}')
146                 docker stop ${running_containers}
147                 all_containers=$(docker ps -a | grep opnfv/qtip | awk '{print $1}')
148                 docker rm ${all_containers}
149             fi
150
151             # Remove existing images if exist
152             if [[ ! -z $(docker images | grep opnfv/qtip) ]]; then
153                 echo "Docker images to remove:"
154                 docker images | head -1 && docker images | grep opnfv/qtip
155                 image_tags=($(docker images | grep opnfv/qtip | awk '{print $2}'))
156                 for tag in "${image_tags[@]}"; do
157                     echo "Removing docker image opnfv/qtip:$tag..."
158                     docker rmi opnfv/qtip:$tag
159                 done
160             fi