9c627b8af865c648fe0547bd48a668caaacf4e4d
[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
109     triggers:
110       - timed: '0 0,13,15,20 * * *'
111
112
113 ###########################
114 #biuilder macros
115 ###########################
116 - builder:
117     name: qtip-set-env
118     builders:
119         - shell: |
120             #!/bin/bash
121             echo "Qtip: Start Docker and prepare environment"
122             envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
123             suite="TEST_CASE=all"
124             docker pull opnfv/qtip:latest
125
126             cmd=" docker run -id -e $envs -e $suite opnfv/qtip:latest /bin/bash"
127             echo "Qtip: Running docker run command: ${cmd}"
128             ${cmd}
129             docker ps -a
130             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
131              if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then
132                 echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..."
133                 exit 1
134             fi
135 - builder:
136     name: qtip-run-suite
137     builders:
138         - shell: |
139             #!/bin/bash
140             echo "The container id is:"
141             container_id=$(docker ps | grep 'opnfv/qtip:latest' | awk '{print $1}' | head -1)
142             echo $container_id
143             QTIP_REPO=/home/opnfv/repos/qtip
144             docker exec -t ${container_id} $QTIP_REPO/docker/run_qtip.sh
145
146
147 - builder:
148     name: qtip-cleanup
149     builders:
150         - shell: |
151             #!/bin/bash
152
153             echo "Cleaning up QTIP  docker containers/images..."
154             # Remove previous running containers if exist
155             if [[ ! -z $(docker ps -a | grep opnfv/qtip) ]]; then
156                 echo "Removing existing opnfv/qtip containers..."
157                 running_containers=$(docker ps | grep opnfv/qtip | awk '{print $1}')
158                 docker stop ${running_containers}
159                 all_containers=$(docker ps -a | grep opnfv/qtip | awk '{print $1}')
160                 docker rm ${all_containers}
161             fi
162
163             # Remove existing images if exist
164             if [[ ! -z $(docker images | grep opnfv/qtip) ]]; then
165                 echo "Docker images to remove:"
166                 docker images | head -1 && docker images | grep opnfv/qtip
167                 image_tags=($(docker images | grep opnfv/qtip | awk '{print $2}'))
168                 for tag in "${image_tags[@]}"; do
169                     echo "Removing docker image opnfv/qtip:$tag..."
170                     docker rmi opnfv/qtip:$tag
171                 done
172             fi
173
174 - builder:
175     name: qtip-fetch-os-cred
176     builders:
177         - shell: |
178             #!/bin/bash
179
180             echo $HOME
181             echo $WORKSPACE
182             cd $WORKSPACE
183             git clone https://gerrit.opnfv.org/gerrit/releng
184             cd $WORKSPACE/releng/utils
185             #./fetch_os_creds.sh                  #To test the problem with creating the file in $HOME
186             ./fetch_os_creds.sh -d $WORKSPACE/opnfv-stack.sh    #To test if  the file can be created in $WORKSPACE