- scm:
    name: jdkX
    scm:
        - hg:
            url: https://hg.openjdk.java.net/jdk/jdk
            clean: true
            subdir: jdkX
- job:
    name: jdkX-ci-build
    project-type: freestyle
    defaults: global
    description: |
        Updates source and builds OpenJDK frequently to ensure builds are successful.
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
            openjdk-members:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 11
            artifact-num-to-keep: 5
    disabled: true
    node: aarch64-06
    display-name: 'DELETE ME'
    scm:
        - jdkX
    wrappers:
        - timestamps
    triggers:
        - pollscm:
            cron: 'H * * * *'
    builders:
        - shell: |
            #!/bin/bash

            set -exu

            ccache_build_opts=--disable-ccache
            # Include when Jtreg tests make sense to be run.
            #rm -rf jtreg
            #tar xJf jtreg-build-4.2.0-SNAPSHOT.tar.xz

            cd $HOME/srv/jdk-cache/jdk14
            export JAVA_HOME=${PWD}

            export PATH=${JAVA_HOME}/bin:${PATH}

            cd ${WORKSPACE}

            shopt -s nullglob

            # Configure and build
            rm -rf build
            mkdir -p build

            which java
            java -version

            rm -rf out
            mkdir out

            pushd build
            sh ../jdkX/configure --with-debug-level=fastdebug \
                ${ccache_build_opts}
            # In future we could trun with jtreg tests, if they run in under 1 hour.
            # --with-jtreg=${WORKSPACE}/jtreg
            make images |& tee ../out/build.out
            popd

            # Take bottom 100 lines of build output, shift it right by two characters
            tail -n 100 out/build.out | sed 's,^,   ,' > build-tail.out

            # Archive the result
            artifact_name=jdkX-ci-build
            tar -C build/images/jdk --exclude=\*.debuginfo --transform="s!^./!$artifact_name/!" -acf out/${artifact_name}.tar.gz .
    publishers:
        - archive:
            artifacts: 'out/*.tar.gz, out/build.out'
        - email-ext:
            reply-to: stuart.monteith@linaro.org
            subject: Linaro OpenJDK AArch64 jdk/jdk build ${BUILD_NUMBER} ${BUILD_STATUS}
            attach-build-log: false
            body: |
                OpenJDK AArch64 jdk/jdk build status is ${BUILD_STATUS}
                Build details -  ${BUILD_URL}

                Changes -
                ${CHANGES, showPaths=true, format="  %a: %r %p \n--\"%m\"", pathFormat="\n\t- %p"}

                Build output -
                ${FILE,path="build-tail.out"}

            fixed: true
            first-failure: true
            failure: false
            success: false
            recipients: 'stuart.monteith@linaro.org, aarch64-port-dev@openjdk.java.net'
