aboutsummaryrefslogtreecommitdiff
path: root/tcwg-make-release.yaml
blob: 6916fb56ba95318e3a06a467810c09767272fa95 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# http://docs.openstack.org/infra/jenkins-job-builder/definition.html
- job:
    name: tcwg-make-release
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 10
    parameters:
        - string:
            name: gcc_src
            default: 'gcc-linaro-5.3-2016.02.tar.xz'
            description: 'The source of GCC. Specify as it would be passed to abe.sh, either a source tarball, git branch and revision, git tag, or a URL of a tarball e.g., "gcc-linaro-5.3-2016.02.tar.xz"'
        - string:
            name: binutils_src
            default: ''
            description: 'Optional revision of binutils to use for this release, e.g., "binutils-gdb.git~linaro_binutils-2_25-branch"'
        - string:
            name: glibc_src
            default: ''
            description: 'Optional revision of Glibc to use for this release, e.g., "glibc.git~linaro/2.21/master"'
        - string:
            name: release_name
            default: ''
            description: 'Optional release string to use, e.g., "2016.05", "2016.05-rc3", "2016.05-1", "2016.05-1-rc2". The default is to extract the release string from the gcc_src field'
        - string:
            name: toolchain_config
            default: 'default'
            description: 'Toolchain version config, e.g., "default", "gcc5", or "gcc6". Relative to abe config/ dir'
        - string:
            name: target_list
            default: 'aarch64-elf aarch64-linux-gnu aarch64_be-elf aarch64_be-linux-gnu armv8l-linux-gnueabihf arm-eabi arm-linux-gnueabi arm-linux-gnueabihf armeb-eabi armeb-linux-gnueabi armeb-linux-gnueabihf'
            description: 'List of targets to use'
        - string:
            name: builder_arch_list
            default: 'i386 amd64'
            description: 'List of builder architectures to use (i386,amd64)'
        - string:
            name: abe_branch
            default: refs/heads/master
            description: 'ABE revision to test'
        - string:
            name: scripts_branch
            default: master
            description: 'Scripts branch to use'
        - choice:
            name: debug
            choices:
                - none
                - abe
                - yaml
            description: "Level of debug information: none - No debugging information, abe - ABE debugging information, yaml - tcwg-make-release.yaml debug information (and exit)."
        - string:
            name: fileserver
            default: dev-01.tcwglab
            description: 'Remote file server for logs and binaries'
        - bool:
            name: testrelease
            default: 'true'
            description: 'Run test-release if make-release is successful'
        - string:
            name: binariesdir
            default: ''
            description: 'Optional upload dir for binaries on fileserver. If empty, a suitable value is computed by the script'
        - string:
            name: logsdir
            default: ''
            description: 'Optional upload dir for logs on fileserver. If empty, a suitable value is computed by the script'
    disabled: false
    node: tcwg-coordinator
    retry-count: 3
    concurrent: true
    display-name: 'TCWG Make Release'
    scm:
        - git:
            url: https://git-us.linaro.org/toolchain/abe.git
            refspec: +refs/changes/*:refs/remotes/changes/*
            branches:
                - ${abe_branch}
            skip-tag: true
            shallow-clone: true
            basedir: abe
    axes:
        - axis:
            type: slave
            name: label
            values:
                - tcwg-x86_64-build
        - axis:
            type: dynamic
            name: builder_arch
            values:
                - builder_arch_list
        - axis:
            type: dynamic
            name: target
            values:
                - target_list
    execution-strategy:
        sequential: false
    wrappers:
        - timeout:
            timeout: 300
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
        - build-name:
            name: '#${BUILD_NUMBER}-${ENV,var="release_name"}'
        - workspace-cleanup:
            include:
              - "*"
            dirmatch: true
    builders:
      - shell: |
            #!/bin/bash
            set -e

            if test x"${debug}" = x"abe"; then
              shell="/bin/bash -x"
              set -x
            else
                shell="/bin/bash"
            fi

            if test x"${debug}" = x"yaml"; then
                echo WORKSPACE:  $WORKSPACE
                echo CURRENTDIR: `pwd`
                ls -lR
                exit 0
            fi

            git clone -b $scripts_branch --depth 1 https://git-us.linaro.org/toolchain/jenkins-scripts

            # Start build container
            build_container_type=docker
            build_container_distro=trusty
            builder=$(./jenkins-scripts/nodename2hostname.sh $NODE_NAME)
            bash -x ./jenkins-scripts/start-container-${build_container_type}.sh --arch ${builder_arch} --distro ${build_container_distro} --session-host ${builder} > build-container.sh

            # Define CONTAINER, CONTAINER_CLEANUP, session_host and session_port
            . ./build-container.sh
            BUILD_CONTAINER="${CONTAINER}"
            BUILD_CONTAINER_CLEANUP="${CONTAINER_CLEANUP}"

            # Make sure to cleanup build container if something goes
            # wrong when preparing the rest of the environment
            if [ x"${BUILD_CONTAINER_CLEANUP}" != x ]; then
                CONTAINERS_CLEANUP="${BUILD_CONTAINER_CLEANUP}"
                trap "${CONTAINERS_CLEANUP}" EXIT
            fi

            tcwg_release=${release_name}
            # If there is no release_name set, extract release information from the gcc_src
            if test "${release_name:+set}" != "set"; then
                case "$gcc_src" in
                *.tar.xz)
                    tcwg_release="$(basename $gcc_src | cut -d '-' -f4-)"
                    tcwg_release=${tcwg_release%".tar.xz"}
                    ;;
                gcc.git~*)
                    tcwg_release="$(echo $gcc_src | grep -o -e '-\(20[0-9]\{2\}\.[01][0-9].*\)' )"
                    tcwg_release=${tcwg_release#-}
                    ;;
                *)
                    echo "ERROR: Could not find tcwg release"
                    exit 1
                    ;;
                esac
            fi

            if [ x"${tcwg_release}" = x"" ]; then
                echo "ERROR: Could not find tcwg release"
                exit 1
            fi

            # This job always uses Canadian cross builds and builds 2
            # toolchains at a time when run on a amd64 slave.
            # When run on a i386 host, no need to duplicate the
            # Canadian cross build for mingw.
            canadian=
            case ${builder_arch} in
              amd64)
                host=x86_64
                canadian=--canadian ;;
              i386)
                host=i686
                canadian= ;;
             *)
                echo "ERROR: unsupported label: ${label}"
                exit 1
                ;;
            esac

            # FIXME. MakeRelease copies to a directory, while
            # TestRelease downloads from a URL, so both dirs differ
            # depending on httpd's DocumentRoot
            # Setting url_prefix can be removed once test-release is
            # started after make-release has completed.
            case ${binariesdir} in
              releases/binaries/*)
                url_prefix=$(echo \~${USER}/${binariesdir})
                ;;
              "")
                # Compute default binariesdirs/logsdir in case they
                # are not supplied by the user. Normally they are set
                # by tcwg-make-and-test-release.

                # Extract the gcc_version information from gcc_src to determine
                # which directory to copy the tarballs into.
                case "$gcc_src" in
                    *.tar.*) # src tarballs usually named like this
                        gcc_version=$(basename $gcc_src | awk -F '-' '{ print $3 }')
                        ;;
                    *.git~*) # building from git branch or tag
                        gcc_version=$(basename $gcc_src | awk -F '-' '{ print $2 }')
                        ;;
                    *)
                        echo "ERROR: could not extract version from gcc_src"
                        exit 1
                        ;;
                esac
                if ! echo "${gcc_version}" | grep -xEq '[0-9]+\.[0-9]+(\.[0-9]+)?'; then
                    echo "ERROR: gcc version '${gcc_version}' invalid"
                    exit 1
                fi

                gcc_major="`echo $gcc_version | awk -F '.' '{ print $1 }'`"
                gcc_minor="`echo $gcc_version | awk -F '.' '{ print $2 }'`"
                tcwg_version="${gcc_major}.${gcc_minor}"
                if test ${gcc_major} -lt 5; then
                    gcc_point="`echo $gcc_version | awk -F '.' '{ print $2 }'`"
                    tcwg_version="${gcc_major}.${gcc_minor}.${gcc_point}"
                fi

                buildid=`printf '%04d' ${BUILD_NUMBER}`

                binariesdir=releases/binaries/${tcwg_version}-${tcwg_release}-${buildid}
                logsdir=releases/logs/${tcwg_version}-${tcwg_release}-${buildid}

                url_prefix=$(echo \~${USER}/${binariesdir})
                ;;
              *)
                echo Unsupported binariesdir: ${binariesdir}. Fix the job.
                ;;
            esac

            ${BUILD_CONTAINER} "cd ${WORKSPACE} && ${shell} ${WORKSPACE}/jenkins-scripts/MakeRelease.job --abedir ${WORKSPACE}/abe --workspace ${WORKSPACE} ${canadian} --target ${target}${tcwg_release:+ --release_name ${tcwg_release}} --fileserver ${fileserver} --toolchainconfig ${toolchain_config} --binariesdir ${binariesdir}/${target} --logsdir ${logsdir}/${target} --buildnumber ${BUILD_NUMBER} ${gcc_src:+ --gcc ${gcc_src}} ${binutils_src:+ --binutils ${binutils_src}} ${glibc_src:+ --glibc ${glibc_src}}"
            if test $? -gt 0; then
              exit 1
            fi

            # tarballs are written in ${WORKSPACE}/snapshots, which is
            # not shared between host and container. So, we need to
            # execute the find command inside the container.

            if test x"${canadian}" = x"true"; then
                linux_artifacts=artifacts1.txt
                mingw_artifacts=artifacts2.txt
            else
                linux_artifacts=artifacts2.txt
            fi

            # We always build a Linux tarball, even in canadian cross mode
            tarball_linux=$(grep "^toolchain=" ${WORKSPACE}/${linux_artifacts} | cut -d = -f 2-)
            if test x"${tarball_linux}" = x"" -o ! -f "${tarball_linux}"; then
              echo "ERROR: no binary Linux tarball found!"
              exit 1
            fi

            if test x"${canadian}" = x"true"; then
              tarball_mingw=$(grep "^toolchain=" ${WORKSPACE}/${mingw_artifacts} | cut -d = -f 2-)
              if test x"${tarball_mingw}" = x"" -o ! -f "${tarball_mingw}"; then
                echo "ERROR: no binary MingW tarball found!"
                exit 1
              fi
            fi

            if $testrelease; then
              tarball_linux="`basename ${tarball_linux}`"
              tarball_linux_url="http://${fileserver}/${url_prefix}/${target}/${tarball_linux}"
              cat << EOF > tcwg.params.linux
            tarball_url=${tarball_linux_url}
            release=${tcwg_release}
            target=${host}-${target}
            EOF

              if test x"${canadian}" = x"true"; then
                tarball_mingw="`basename ${tarball_mingw}`"
                tarball_mingw_url="http://${fileserver}/${url_prefix}/${target}/${tarball_mingw}"
                cat << EOF > tcwg.params.mingw
            tarball_url=${tarball_mingw_url}
            release=${tcwg_release}
            target=mingw-${target}
            EOF
              fi
            fi

      - conditional-step:
          condition-kind: file-exists
          condition-filename: tcwg.params.linux
          steps:
              - trigger-builds:
                  - project: 'tcwg-test-release'
                    property-file: tcwg.params.linux
                    current-parameters: true
                    block: false
      - conditional-step:
          condition-kind: file-exists
          condition-filename: tcwg.params.mingw
          steps:
              - trigger-builds:
                  - project: 'tcwg-test-release'
                    property-file: tcwg.params.mingw
                    current-parameters: true
                    block: false
    publishers:
        - archive:
            artifacts: 'MakeRelease*.log.xz'
            latest-only: false
        - email:
            recipients: 'ryan.arnold@linaro.org'
        - email-ext:
            recipients: 'christophe.lyon@linaro.org'
            send-to:
              requester
              recipients