aboutsummaryrefslogtreecommitdiff
path: root/post-build-repo.yaml
blob: e7f42c76770d44776780fc7a2193d24d0c13c9a3 (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
- job:
    name: post-build-repo
    project-type: freestyle
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-read
                - job-extended-read
                - job-build
                - job-cancel
    parameters:
        - file:
            name: post_build_ppa_parameters
            description: "where to find changes file"
    disabled: false
    node: master
    display-name: 'Upload packages to repo.linaro.org'
    wrappers:
        - timestamps
    builders:
        - shell: |
            #!/bin/bash
            set -e
            echo "Build success: ${build_success}"
            echo "Package job name: ${pkg_job_name}"
            echo "Debsign key ID: ${key_id}"
            echo "Package changes file: ${pkg_changes}"
            echo "Host repo: ${host_ppa}"
            [  "${build_success}" = "false" ] && exit 0

            job_path=/var/lib/jenkins/jobs/${pkg_job_name}/workspace/
            job_path_axis=$(echo ${job_path} | sed -e 's,/label=,/configurations/axis-label/,')
            temp=$(echo ${pkg_job_name} | sed -e 's,/,/workspace/,' -e 's,=,/,')
            job_path_matrix=/var/lib/jenkins/jobs/${temp}/

            for path in ${job_path} ${job_path_axis} ${job_path_matrix}
            do
                if [ -r "${path}/${pkg_changes}" ]
                then
                    cd ${path}
                    break
                fi
            done

            if [ -n "${pkg_url}" ]; then
                echo "Source URL: ${pkg_url}"
                # workaround race where post-build-repo gets called too early
                timeout=5
                set +e
                while [ true ]; do
                    wget --no-check-certificate --progress=dot -e dotbytes=1M ${pkg_url}/${pkg_changes}
                    [ -r "${pkg_changes}" ] && break
                    sleep 60
                    timeout=$((timeout - 1))
                    [ $timeout -eq 0 ] && break
                done
                set -e

                for file in $(dcmd ${pkg_changes})
                do
                    wget --no-check-certificate --progress=dot -e dotbytes=1M ${pkg_url}/${file}
                done
            fi
            chmod 0700 ~/.ssh/
            chmod 0600 ~/.ssh/*

            ls -l .
            if [ ! -r "${pkg_changes}" ]; then
                echo "${pkg_changes} missing"
                exit 1
            fi
            debsign -k${key_id} ${pkg_changes}
            dput ${host_ppa} ${pkg_changes}
            set +e
            logname=${pkg_changes/changes/log}
            ssh upload@repo.linaro.org curl -o /srv/repos/ubuntu/$host_ppa/incoming/$logname $pkg_build_url/consoleText
            for file in $(dcmd ${pkg_changes})
            do
                 rm -f $file
            done
            rm -f ${pkg_changes} *.upload
            find . -mtime +1 -exec rm -f {} \;
    publishers:
        - email:
            recipients: 'packages@lists.linaro.org'