aboutsummaryrefslogtreecommitdiff
path: root/tcwg-cleanup-results-master.yaml
blob: e7cea6b45b127a0f1caaaafa6b2812f880733a37 (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
- job:
    name: tcwg-cleanup-results-master
    project-type: freestyle
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
                - job-workspace
    parameters:
        - string:
            name: log_name
            default: tcwg-backport-SHA1/$host.$target
            description: 'Log directory on $log_server to remove; you can use shell wildcards'
        - string:
            name: log_server
            default: ex40-01.tcwglab.linaro.org:logs-test
            description: 'Log_Server'
    disabled: false
    node: tcwg-x86_64-ex40 || tcwg-x86_64-ex40build-01
    retry-count: 3
    display-name: 'Cleanup results'
    wrappers:
        - timeout:
            timeout: 60
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
        - build-name:
            name: '#${BUILD_NUMBER}-${ENV,var="log_name"}'
    builders:
        - shell: |
            #!/bin/bash

            set -e
            set -x

            basedir="${log_server#*:}"
            log_server="${log_server%:*}"

            # These lists need to be kept up-to-date with tcwg-buildfarm-master job.
            hosts=(
              aarch64
              x86_64
            )
            targets=(
              aarch64-linux-gnu
              aarch64-none-elf
              aarch64_be-none-elf
              arm-linux-gnueabi
              arm-linux-gnueabihf
              armeb-linux-gnueabihf
              native
              schroot-i386-native
              schroot-armhf-native
            )

            # Disable shell wild-card expansion to handle $log_names with wildcards.
            set -f
            dirs=""
            for host in "${hosts[@]}"; do
              for target in "${targets[@]}"; do
                eval "dirs=\"$dirs $basedir/$log_name\""
              done
            done

            dirs="$(echo "$dirs" | sort -u)"

            ssh $log_server "rm -rf $dirs"
            set +f