f901afe74e26e492442dbdd3d6031dd524030ac6
[releng.git] / jjb / xci / bifrost-cleanup-job.yml
1 ---
2 - project:
3     name: 'openstack-bifrost-cleanup'
4     # -------------------------------
5     # branches
6     # -------------------------------
7     stream:
8       - master:
9           branch: '{stream}'
10
11     # -------------------------------
12     # projects
13     # -------------------------------
14     project:
15       - 'openstack':
16           project-repo: 'https://git.openstack.org/openstack/bifrost'
17           clone-location: '/opt/bifrost'
18       - 'opnfv':
19           project-repo: 'https://gerrit.opnfv.org/gerrit/releng-xci'
20           clone-location: '/opt/releng-xci'
21
22     # -------------------------------
23     # jobs
24     # -------------------------------
25     jobs:
26       - '{project}-bifrost-cleanup-{stream}'
27
28 - job-template:
29     name: '{project}-bifrost-cleanup-{stream}'
30
31     concurrent: false
32
33     node: bifrost-verify-virtual
34
35     # Make sure no verify job is running on any of the slaves since that would
36     # produce build logs after we wipe the destination directory.
37     properties:
38       - build-blocker:
39           blocking-jobs:
40             - '{project}-bifrost-verify-*'
41
42     parameters:
43       - string:
44           name: PROJECT
45           default: '{project}'
46
47     builders:
48       - shell: |
49           #!/bin/bash
50
51           set -eu
52
53           # DO NOT change this unless you know what you are doing.
54           BIFROST_GS_URL="gs://artifacts.opnfv.org/cross-community-ci/openstack/bifrost/$GERRIT_NAME/$GERRIT_CHANGE_NUMBER/"
55
56           # This should never happen... even 'recheck' uses the last jobs'
57           # gerrit information. Better exit with error so we can investigate
58           [[ ! -n $GERRIT_NAME ]] || [[ ! -n $GERRIT_CHANGE_NUMBER ]] && exit 1
59
60           echo "Removing build artifacts for $GERRIT_NAME/$GERRIT_CHANGE_NUMBER"
61
62           if ! [[ "$BIFROST_GS_URL" =~ "/cross-community-ci/openstack/bifrost/" ]]; then
63               echo "Oops! BIFROST_GS_URL=$BIFROST_GS_URL does not seem like a valid"
64               echo "bifrost location on the Google storage server. Please double-check"
65               echo "that it's set properly or fix this line if necessary."
66               echo "gsutil will not be executed until this is fixed!"
67               exit 1
68           fi
69           try_to_rm=1
70           while [[ $try_to_rm -lt 6 ]]; do
71               gsutil -m rm -r $BIFROST_GS_URL && _exitcode=$? && break
72               _exitcode=$?
73               echo "gsutil rm failed! Trying again... (attempt #$try_to_rm)"
74               let try_to_rm += 1
75               # Give it some time...
76               sleep 10
77           done
78           exit $_exitcode
79
80     triggers:
81       - '{project}-gerrit-trigger-cleanup':
82           branch: '{branch}'
83
84     publishers:
85       # yamllint disable rule:line-length
86       - email:
87           recipients: fatih.degirmenci@ericsson.com yroblamo@redhat.com mchandras@suse.de jack.morgan@intel.com zhang.jun3g@zte.com.cn
88       # yamllint enable rule:line-length
89       - email-jenkins-admins-on-failure
90 # -------------------------------
91 # trigger macros
92 # -------------------------------
93 - trigger:
94     name: 'openstack-gerrit-trigger-cleanup'
95     triggers:
96       - gerrit:
97           server-name: 'review.openstack.org'
98           escape-quotes: true
99           trigger-on:
100             # We only run this when the change is merged or
101             # abandoned since we don't need the logs anymore
102             - change-merged-event
103             - change-abandoned-event
104           # This is an OPNFV maintenance job. We don't want to provide
105           # feedback on Gerrit
106           silent: true
107           silent-start: true
108           projects:
109             - project-compare-type: 'PLAIN'
110               project-pattern: 'openstack/bifrost'
111               branches:
112                 - branch-compare-type: 'ANT'
113                   branch-pattern: '**/{branch}'
114               disable-strict-forbidden-file-verification: 'true'
115               forbidden-file-paths:
116                 - compare-type: ANT
117                   pattern: 'doc/**'
118                 - compare-type: ANT
119                   pattern: 'releasenotes/**'
120           readable-message: true
121
122 - trigger:
123     name: 'opnfv-gerrit-trigger-cleanup'
124     triggers:
125       - gerrit:
126           server-name: 'gerrit.opnfv.org'
127           trigger-on:
128             # We only run this when the change is merged or
129             # abandoned since we don't need the logs anymore
130             - change-merged-event
131             - change-abandoned-event
132           # This is an OPNFV maintenance job. We don't want to provide
133           # feedback on Gerrit
134           silent: true
135           silent-start: true
136           projects:
137             - project-compare-type: 'ANT'
138               project-pattern: 'releng-xci'
139               branches:
140                 - branch-compare-type: 'ANT'
141                   branch-pattern: '**/{branch}'
142               file-paths:
143                 - compare-type: ANT
144                   pattern: 'bifrost/**'
145           readable-message: true