aboutsummaryrefslogtreecommitdiff
path: root/odp-publish-icon.yaml
blob: 4c666ed9e509f6520daf9277ba3e1d05e51b9e39 (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
- job:
    name: odp-publish-icon
    project-type: freestyle
    defaults: global
    description: |
        * ODP publish icon.
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-read
                - job-extended-read
                - job-build
                - job-cancel
        - build-discarder:
            num-to-keep: 30
            days-to-keep: 30
    parameters:
        - string:
            name: UPSTREAM_BUILD_URL
            default: ''
        - string:
            name: UPSTREAM_GIT_BRANCH
            default: 'master'
    disabled: false
    node: master
    child-workspace: .
    display-name: 'ODP publish icon'
    wrappers:
        - timestamps
        - build-name:
            name: '#${BUILD_NUMBER}-${GIT_REVISION,length=8}'
        - timeout:
            timeout: 20
    builders:
        - linaro-publish-token
        - shell: |
            #!/bin/bash

            set -ex

            # Prepare to publish to docs.opendataplane.org/snapshots
            mkdir -p doc_snapshots
            wget -q ${UPSTREAM_BUILD_URL}/badge/icon -O doc_snapshots/icon

            # Construct URL
            trimmed_build_url=$(echo ${UPSTREAM_BUILD_URL} | sed 's|.*jenkins/job/||g')
            upstream_job_name=$(echo ${trimmed_build_url} | awk -F'/' '{print $1}')
            upstream_axis=$(echo ${trimmed_build_url} | awk -F'/' '{print $2}')
            upstream_buildnumber=$(echo ${trimmed_build_url} | awk -F'/' '{print $3}')

            construct_publish_path=${upstream_job_name}/${UPSTREAM_GIT_BRANCH}
            for axis in $(echo $( echo ${upstream_axis}| sed 's|,| |g')); do
                construct_publish_path=${construct_publish_path}/$(echo ${axis}|awk -F'=' '{print $2}')
            done

            cat << EOF > remote_directory_parameters
            upstream_buildnumber=${upstream_buildnumber}
            construct_publish_path=${construct_publish_path}
            EOF

        - inject:
            properties-file: remote_directory_parameters
        - ssh:
            site: 'docs.opendataplane.org'
            target: 'incoming/${construct_publish_path}/${upstream_buildnumber}'
            source: 'doc_snapshots/**'
            command: |
                cd /srv/docs.opendataplane.org
                mkdir -p snapshots/${construct_publish_path}/${upstream_buildnumber}
                cp -a incoming/${construct_publish_path}/${upstream_buildnumber}/icon snapshots/${construct_publish_path}/${upstream_buildnumber}
                rm -rf $(pwd)/snapshots/${construct_publish_path}/latest
                ln -sf $(pwd)/snapshots/${construct_publish_path}/${upstream_buildnumber} snapshots/${construct_publish_path}/latest
                rm -rf incoming/${construct_publish_path}/${upstream_buildnumber}
            timeout: 120000
            remove-prefix: 'doc_snapshots'
            always-publish-from-master: true
    publishers:
        - warnings:
            console-log-parsers:
              - 'GNU Make + GNU C Compiler (gcc)'
        - email:
            recipients: 'anders.roxell@linaro.org, fathi.boudra@linaro.org'