aboutsummaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-results.yaml
blob: 211141404877c560baad30e983c76f1a160b74c3 (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
# Auto generated by ./tcwg/generate-yamlfiles.sh from tcwg-cleanup-stale-results.yaml.in and tcwg-cleanup-stale-results/tcwg-cleanup-stale-results.def. Do not edit.
#BEGIN: tcwg/default.yaml.inc
# -*- mode: Yaml -*-

- property:
    name: default-properties
    properties:
      - authorization:
          anonymous:
            - job-read
            - job-extended-read
          everyone-flat:
            - job-build
            - job-cancel
      - build-discarder:
          days-to-keep: 30

- scm:
    name: jenkins-scripts-master
    scm:
      - git:
          url: https://git.linaro.org/toolchain/jenkins-scripts.git
          refspec: +refs/heads/master:refs/remotes/origin/master
          branches:
            - master
          basedir: jenkins-scripts
          skip-tag: true
          reference-repo: /home/tcwg-buildslave/snapshots-ref/jenkins-scripts.git
          wipe-workspace: false
          clean:
            before: true
          prune: true

#END:   tcwg/default.yaml.inc

- job:
    name: tcwg-cleanup-stale-results
    project-type: freestyle
    defaults: global
    properties:
        - default-properties
    parameters:
        - choice:
            name: cleanup_gc
            choices:
              - 'true'
              - 'dryrun'
              - 'false'
            description: 'Cleanup the git repositories'
        - choice:
            name: cleanup_annex
            choices:
              - 'dryrun'
              - 'true'
              - 'false'
            description: 'Cleanup the annex results files'
        - bool:
            name: verbose
            default: 'false'
            description: 'Whether to be verbose'
    disabled: false
    node: tcwg-bkp-01
    concurrent: false
    display-name: 'TCWG CCC Cleanup stale results'
    workspace: workspace/tcwg-cleanup-stale-results
    triggers:
        - timed: '@daily'
    scm:
        - jenkins-scripts-master
    wrappers:
        - timeout:
            timeout: 600
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}'
    builders:
        - shell: |
            #!/bin/bash
            set -ex

            rm -rf artifacts
            mkdir artifacts

            ./jenkins-scripts/tcwg-cleanup-stale-results.sh \
            --cleanup_gc $cleanup_gc \
            --cleanup_annex $cleanup_annex \
            --verbose $verbose

            if [ x"$(cat list_annex.exist_but_not_referenced.txt | wc -l)" != x"0" ]; then
              (
                if [ "$cleanup_annex" = "dryrun" ]; then
                  echo "# Cleanup-stale-results was run in DRYRUN mode."
                  echo "# Please double check and run this script manually."
                else
                  echo "# Cleanup-stale-results executed the following"
                fi
                echo "#"
                echo "# List of missing results :"
                sed -e 's|^|#     |' list_annex.referenced_but_not_exist.txt
                echo "#"
                echo "# List of useless results :"
                sed -e 's|^|rm -f |' list_annex.exist_but_not_referenced.txt
                echo ""
              ) > artifacts/email-body.txt
              exit 1
            fi

    publishers:
        - archive:
            artifacts: 'artifacts/**'
            latest-only: false
        - email-ext:
            recipients: 'maxim.kuvyrkov@linaro.org, laurent.alfonsi@linaro.org'
            content-type: text
            body: |
              ${FILE,path="artifacts/email-body.txt"}
            failure: true
            aborted: true
# checksum: b82d7a10cb9e3dc101d3faaf2ecc565d