51782a255b0dbb3cb7e71b702028d9f32b392a8c
[releng.git] / jjb / bottlenecks / bottlenecks-project-jobs.yml
1 ###################################################
2 # Non-ci jobs for Bottlenecks project
3 # They will only be enabled on request by projects!
4 ###################################################
5 - project:
6     name: bottlenecks-project-jobs
7
8     project: 'bottlenecks'
9
10     jobs:
11         - 'bottlenecks-verify-{stream}'
12         - 'bottlenecks-merge-{stream}'
13         - 'bottlenecks-{suite}-upload-artifacts-{stream}'
14
15     stream:
16         - master:
17             branch: '{stream}'
18             #This is used for common project file storage
19             gs-pathname: ''
20             #This is used for different test suite dependent packages storage
21             gs-packagepath: '/{suite}'
22             disabled: false
23         - colorado:
24             branch: 'stable/{stream}'
25             gs-pathname: '/{stream}'
26             gs-packagepath: '/{stream}/{suite}'
27             disabled: false
28
29     suite:
30         - 'rubbos'
31         - 'vstf'
32
33 ################################
34 # job templates
35 ################################
36
37 - job-template:
38     name: 'bottlenecks-verify-{stream}'
39
40     disabled: '{obj:disabled}'
41
42     parameters:
43         - project-parameter:
44             project: '{project}'
45         - gerrit-parameter:
46             branch: '{branch}'
47         - 'opnfv-build-ubuntu-defaults'
48
49     scm:
50         - gerrit-trigger-scm:
51             credentials-id: '{ssh-credentials}'
52             refspec: '$GERRIT_REFSPEC'
53             choosing-strategy: 'gerrit'
54
55     triggers:
56         - gerrit:
57             trigger-on:
58                 - patchset-created-event:
59                     exclude-drafts: 'false'
60                     exclude-trivial-rebase: 'false'
61                     exclude-no-code-change: 'false'
62                 - draft-published-event
63                 - comment-added-contains-event:
64                     comment-contains-value: 'recheck'
65                 - comment-added-contains-event:
66                     comment-contains-value: 'reverify'
67             projects:
68               - project-compare-type: 'ANT'
69                 project-pattern: '{project}'
70                 branches:
71                   - branch-compare-type: 'ANT'
72                     branch-pattern: '**/{branch}'
73     builders:
74         - bottlenecks-unit-tests
75
76 - job-template:
77     name: 'bottlenecks-merge-{stream}'
78
79     disabled: '{obj:disabled}'
80
81     parameters:
82         - project-parameter:
83             project: '{project}'
84         - gerrit-parameter:
85             branch: '{branch}'
86         - 'opnfv-build-ubuntu-defaults'
87
88     scm:
89         - gerrit-trigger-scm:
90             credentials-id: '{ssh-credentials}'
91             refspec: ''
92             choosing-strategy: 'default'
93
94     triggers:
95         - gerrit:
96             trigger-on:
97                 - change-merged-event
98                 - comment-added-contains-event:
99                     comment-contains-value: 'remerge'
100             projects:
101               - project-compare-type: 'ANT'
102                 project-pattern: '{project}'
103                 branches:
104                     - branch-compare-type: 'ANT'
105                       branch-pattern: '**/{branch}'
106
107     builders:
108         - bottlenecks-unit-tests
109
110 - job-template:
111     name: 'bottlenecks-{suite}-upload-artifacts-{stream}'
112
113
114     disabled: '{obj:disabled}'
115
116     concurrent: true
117
118     properties:
119         - throttle:
120             enabled: true
121             max-total: 1
122             max-per-node: 1
123             option: 'project'
124
125     parameters:
126         - project-parameter:
127             project: '{project}'
128         - 'opnfv-build-ubuntu-defaults'
129         - bottlenecks-parameter:
130             gs-packagepath: '{gs-packagepath}'
131
132     scm:
133         - git-scm:
134             credentials-id: '{ssh-credentials}'
135             refspec: ''
136             branch: '{branch}'
137
138     builders:
139         - 'bottlenecks-builder-upload-artifact'
140         - 'bottlenecks-workspace-cleanup'
141
142 ####################
143 # parameter macros
144 ####################
145 - parameter:
146     name: bottlenecks-parameter
147     parameters:
148         - string:
149            name: CACHE_DIR
150            default: $WORKSPACE/cache{gs-packagepath}
151            description: "the cache to store packages downloaded from public IP"
152         - string:
153            name: SUITE_URL
154            default: gs://artifacts.opnfv.org/bottlenecks{gs-packagepath}
155            description: "LF artifacts url for storage of bottlenecks packages"
156         - string:
157            name: PACKAGE_URL
158            default: http://205.177.226.237:9999/bottlenecks{gs-packagepath}/
159            description: "the url where we store the packages used for bottlenecks rubbos"
160
161 ####################################
162 #builders for bottlenecks project
163 ####################################
164 - builder:
165     name: bottlenecks-builder-upload-artifact
166     builders:
167         - shell: |
168             #!/bin/bash
169             set -o errexit
170
171             echo "Bottlenecks: upload to artifacts from the public IP"
172
173             [[ -d $CACHE_DIR ]] || mkdir -p $CACHE_DIR
174
175             for file in $(curl -s $PACKAGE_URL |
176                                grep href |
177                                sed 's/.*href="//' |
178                                sed 's/".*//' |
179                                grep '^[a-zA-Z].*'); do
180                  curl --connect-timeout 10 -o $CACHE_DIR/$file $PACKAGE_URL$file -v
181                  echo "bottlenecks: copy file $CACHE_DIR/$file to $SUITE_URL"
182                  gsutil cp $CACHE_DIR/$file $SUITE_URL
183             done
184
185 - builder:
186     name: bottlenecks-workspace-cleanup
187     builders:
188         - shell: |
189             #!/bin/bash
190             set -o errexit
191
192             echo "Bottlenecks: cleanup cache used for storage downloaded packages"
193
194             /bin/rm -rf $CACHE_DIR
195
196 - builder:
197     name: bottlenecks-unit-tests
198     builders:
199         - shell: |
200             #!/bin/bash
201             set -o errexit
202             set -o pipefail
203
204             echo "Running unit tests..."
205             cd $WORKSPACE
206             virtualenv $WORKSPACE/bottlenecks_venv
207             source $WORKSPACE/bottlenecks_venv/bin/activate
208
209             # install python packages
210             easy_install -U setuptools
211             easy_install -U pip
212             pip install -r requirements.txt
213
214             # unit tests
215             /bin/bash $WORKSPACE/tests.sh
216
217             deactivate