450ba938e143e3a258fa2784029f4f0fc0eced4f
[releng.git] / jjb / qtip / qtip.yml
1 - project:
2     name: qtip
3
4     project: '{name}'
5
6     jobs:
7         - 'qtip-verify-{stream}'
8         - 'qtip-{installer_type}-{pod}-daily-{stream}'
9
10     pod:
11         - dell-us-testing-bm-1:
12            node: 'dell-us-testing-bm-1'
13            installer_type: 'fuel'
14            installer_ip: '10.20.0.2'
15         - dell-us-deploying-bm3:
16            node: 'dell-us-deploying-bm3'
17            installer_type: 'fuel'
18            installer_ip: '10.20.0.2'
19
20 # only master branch is enabled at the moment to keep no of jobs sane
21     stream:
22         - master:
23             branch: 'master'
24             gs-pathname: ''
25 #        - brahmaputra:
26 #            branch: 'stable/brahmaputra'
27 #            gs-pathname: '/brahmaputra'
28
29 - job-template:
30     name: 'qtip-verify-{stream}'
31
32     parameters:
33         - project-parameter:
34             project: '{project}'
35         - gerrit-parameter:
36             branch: '{branch}'
37         - 'opnfv-build-defaults'
38
39     scm:
40         - gerrit-trigger-scm:
41             credentials-id: '{ssh-credentials}'
42             refspec: '$GERRIT_REFSPEC'
43             choosing-strategy: 'gerrit'
44
45     triggers:
46         - gerrit:
47             trigger-on:
48                 - patchset-created-event:
49                     exclude-drafts: 'false'
50                     exclude-trivial-rebase: 'false'
51                     exclude-no-code-change: 'false'
52                 - draft-published-event
53                 - comment-added-contains-event:
54                     comment-contains-value: 'recheck'
55                 - comment-added-contains-event:
56                     comment-contains-value: 'reverify'
57             projects:
58               - project-compare-type: 'ANT'
59                 project-pattern: '{project}'
60                 branches:
61                   - branch-compare-type: 'ANT'
62                     branch-pattern: '**/{branch}'
63                 forbidden-file-paths:
64                   - compare-type: ANT
65                     pattern: 'docs/**|.gitignore'
66
67     builders:
68         - shell: |
69             echo "Nothing to verify!"
70
71 - job-template:
72     name: 'qtip-{installer_type}-{pod}-daily-{stream}'
73
74     disabled: false
75
76     node: '{node}'
77
78     parameters:
79       - project-parameter:
80           project: '{project}'
81       - string:
82           name: INSTALLER_TYPE
83           default: '{installer_type}'
84           description: "Installer name that is used for deployment."
85       - string:
86           name: INSTALLER_IP
87           default: '{installer_ip}'
88           description: "Installer IP"
89       - string:
90           name: NODE_NAME
91           default: '{node}'
92           description: "Name of the POD"
93       - string:
94           name: GIT_BASE
95           default: https://gerrit.opnfv.org/gerrit/$PROJECT
96           description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
97
98     scm:
99        - git-scm:
100            credentials-id: '{ssh-credentials}'
101            refspec: ''
102            branch: master
103
104     builders:
105         - 'qtip-cleanup'
106         - 'qtip-set-env'
107         - 'qtip-run-suite'
108         - 'qtip-pushtoDB'
109
110     triggers:
111       - timed: '0 0,13,15,20 * * *'
112
113
114 ###########################
115 #biuilder macros
116 ###########################
117 - builder:
118     name: qtip-set-env
119     builders:
120         - shell: |
121             #!/bin/bash
122             echo "Qtip: Start Docker and prepare environment"
123             envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
124             suite="TEST_CASE=all"
125             docker pull opnfv/qtip:latest
126
127             cmd=" docker run -id -e $envs -e $suite opnfv/qtip:latest /bin/bash"
128             echo "Qtip: Running docker run command: ${cmd}"
129             ${cmd}
130             docker ps -a
131             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
132              if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then
133                 echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..."
134                 exit 1
135             fi
136 - builder:
137     name: qtip-run-suite
138     builders:
139         - shell: |
140             #!/bin/bash
141             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
142             if [[ ! -z ${container_id} ]]; then
143                 echo "The container ID is: ${container_id}"
144                 QTIP_REPO=/home/opnfv/repos/qtip
145                 docker exec -t ${container_id} $QTIP_REPO/docker/run_qtip.sh
146             else
147                 echo "Container ID not available"
148             fi
149
150 - builder:
151     name: qtip-pushtoDB
152     builders:
153         - shell: |
154             #!/bin/bash
155
156             echo "Pushing available results to DB"
157             echo "The container id is:"
158             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
159             if [[ ! -z ${container_id} ]]; then
160                 echo "The condiner ID is: ${container_id}"
161                 QTIP_REPO=/home/opnfv/repos/qtip
162                 docker exec -t ${container_id} $QTIP_REPO/docker/push_db.sh
163             else
164                 echo "Container ID not available"
165             fi
166
167 - builder:
168     name: qtip-cleanup
169     builders:
170         - shell: |
171             #!/bin/bash
172
173             echo "Cleaning up QTIP  docker containers/images..."
174             # Remove previous running containers if exist
175             if [[ ! -z $(docker ps -a | grep opnfv/qtip) ]]; then
176                 echo "Removing existing opnfv/qtip containers..."
177                 running_containers=$(docker ps | grep opnfv/qtip | awk '{print $1}')
178                 docker stop ${running_containers}
179                 all_containers=$(docker ps -a | grep opnfv/qtip | awk '{print $1}')
180                 docker rm ${all_containers}
181             fi
182
183             # Remove existing images if exist
184             if [[ ! -z $(docker images | grep opnfv/qtip) ]]; then
185                 echo "Docker images to remove:"
186                 docker images | head -1 && docker images | grep opnfv/qtip
187                 image_tags=($(docker images | grep opnfv/qtip | awk '{print $2}'))
188                 for tag in "${image_tags[@]}"; do
189                     echo "Removing docker image opnfv/qtip:$tag..."
190                     docker rmi opnfv/qtip:$tag
191                 done
192             fi
193
194 - builder:
195     name: qtip-fetch-os-cred
196     builders:
197         - shell: |
198             #!/bin/bash
199
200             echo $HOME
201             echo $WORKSPACE
202             cd $WORKSPACE
203             git clone https://gerrit.opnfv.org/gerrit/releng
204             cd $WORKSPACE/releng/utils
205             #./fetch_os_creds.sh                  #To test the problem with creating the file in $HOME
206             ./fetch_os_creds.sh -d $WORKSPACE/opnfv-stack.sh    #To test if  the file can be created in $WORKSPACE