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