summaryrefslogtreecommitdiffstats
path: root/jjb/xci/bifrost-cleanup-job.yml
blob: 998464a5ee9c2a20ac45d10c7c9eccdde876502d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
- project:
    name: 'openstack-bifrost-cleanup'
#--------------------------------
# branches
#--------------------------------
    stream:
        - master:
            branch: '{stream}'

#--------------------------------
# projects
#--------------------------------
    project:
        - 'openstack':
            project-repo: 'https://git.openstack.org/openstack/bifrost'
            clone-location: '/opt/bifrost'
        - 'opnfv':
            project-repo: 'https://gerrit.opnfv.org/gerrit/releng'
            clone-location: '/opt/releng'

#--------------------------------
# jobs
#--------------------------------
    jobs:
        - '{project}-bifrost-cleanup-{stream}'

- job-template:
    name: '{project}-bifrost-cleanup-{stream}'

    concurrent: false

    node: bifrost-verify-virtual

    # Make sure no verify job is running on any of the slaves since that would
    # produce build logs after we wipe the destination directory.
    properties:
        - build-blocker:
            blocking-jobs:
                - '{project}-bifrost-verify-*'

    parameters:
        - string:
            name: PROJECT
            default: '{project}'

    builders:
        - shell: |
            #!/bin/bash

            set -eu

            # DO NOT change this unless you know what you are doing.
            BIFROST_GS_URL="gs://artifacts.opnfv.org/cross-community-ci/openstack/bifrost/$GERRIT_NAME/$GERRIT_CHANGE_NUMBER/"

            # This should never happen... even 'recheck' uses the last jobs'
            # gerrit information. Better exit with error so we can investigate
            [[ ! -n $GERRIT_NAME ]] || [[ ! -n $GERRIT_CHANGE_NUMBER ]] && exit 1

            echo "Removing build artifacts for $GERRIT_NAME/$GERRIT_CHANGE_NUMBER"

            if ! [[ "$BIFROST_GS_URL" =~ "/cross-community-ci/openstack/bifrost/" ]]; then
                echo "Oops! BIFROST_GS_URL=$BIFROST_GS_URL does not seem like a valid"
                echo "bifrost location on the Google storage server. Please double-check"
                echo "that it's set properly or fix this line if necessary."
                echo "gsutil will not be executed until this is fixed!"
                exit 1
            fi
            try_to_rm=1
            while [[ $try_to_rm -lt 6 ]]; do
                gsutil -m rm -r $BIFROST_GS_URL && _exitcode=$? && break
                _exitcode=$?
                echo "gsutil rm failed! Trying again... (attempt #$try_to_rm)"
                let try_to_rm += 1
                # Give it some time...
                sleep 10
            done
            exit $_exitcode

    triggers:
        - '{project}-gerrit-trigger-cleanup':
            branch: '{branch}'

    publishers:
        - email:
            recipients: fatih.degirmenci@ericsson.com yroblamo@redhat.com mchandras@suse.de jack.morgan@intel.com zhang.jun3g@zte.com.cn
        - email-jenkins-admins-on-failure
#--------------------------------
# trigger macros
#--------------------------------
- trigger:
    name: 'openstack-gerrit-trigger-cleanup'
    triggers:
        - gerrit:
            server-name: 'review.openstack.org'
            escape-quotes: true
            trigger-on:
                # We only run this when the change is merged or
                # abandoned since we don't need the logs anymore
                - change-merged-event
                - change-abandoned-event
            # This is an OPNFV maintenance job. We don't want to provide
            # feedback on Gerrit
            silent: true
            silent-start: true
            projects:
              - project-compare-type: 'PLAIN'
                project-pattern: 'openstack/bifrost'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                disable-strict-forbidden-file-verification: 'true'
                forbidden-file-paths:
                  - compare-type: ANT
                    pattern: 'doc/**'
                  - compare-type: ANT
                    pattern: 'releasenotes/**'
                disable-strict-forbidden-file-verification: 'true'
            readable-message: true
- trigger:
    name: 'opnfv-gerrit-trigger-cleanup'
    triggers:
        - gerrit:
            server-name: 'gerrit.opnfv.org'
            trigger-on:
                # We only run this when the change is merged or
                # abandoned since we don't need the logs anymore
                - change-merged-event
                - change-abandoned-event
            # This is an OPNFV maintenance job. We don't want to provide
            # feedback on Gerrit
            silent: true
            silent-start: true
            projects:
              - project-compare-type: 'ANT'
                project-pattern: 'releng'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'prototypes/bifrost/**'
            readable-message: true