- scm:
    name: jdk8
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah
            clean: true
            subdir: jdk8u
- scm:
    name: corba
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/corba
            clean: true
            subdir: jdk8u/corba
- scm:
    name: hotspot
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/hotspot
            clean: true
            subdir: jdk8u/hotspot
- scm:
    name: jaxp
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/jaxp
            clean: true
            subdir: jdk8u/jaxp
- scm:
    name: jaxws
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/jaxws
            clean: true
            subdir: jdk8u/jaxws
- scm:
    name: jdk
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/jdk
            clean: true
            subdir: jdk8u/jdk
- scm:
    name: langtools
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/langtools
            clean: true
            subdir: jdk8u/langtools
- scm:
    name: nashorn
    scm:
        - hg:
            url: https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah/nashorn
            clean: true
            subdir: jdk8u/nashorn
- job:
    name: jdk8-update-src-tree
    project-type: freestyle
    defaults: global
    description: |
        This job polls upstream Mercurial servers for changes and,<br>
        if there are any, triggers "jdk8-build-and-test".<br>
        Note: this job archives the src which is later required by the jtreg<br>
        report and publish job. The build-date.sh artefact contains shell<br>
        variables for the day and day-of-year the source was archived.
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            openjdk-members:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 10
            artifact-num-to-keep: 5
        - build-blocker:
            use-build-blocker: true
            blocking-jobs:
                - "jdk14-.*"
                - "jdk13-.*"
                - "jdk11-.*"
                - "jdkX-.*"
            block-level: 'GLOBAL'
    disabled: true
    node: j12-qrep-01
    display-name: 'DELETE ME'
    scm:
        - jdk8
        - corba
        - hotspot
        - jaxp
        - jaxws
        - jdk
        - langtools
        - nashorn
    triggers:
        - pollscm:
            cron: '0 7 * * 2,4,6'
    wrappers:
        - timestamps
    builders:
        - shell: |
            #!/bin/bash

            set -eu

            rm -rf out
            mkdir out

            pushd jdk8u
            #find . -name BOM -exec rm {} \;
            #commit_id=$(hg identify | awk '{print $1}')
            #echo "jdk9-${commit_id}" | tee -a BOM

            #for i in corba jaxp jaxws langtools jdk hotspot nashorn; do
            #  pushd $i
            #  commit_id=$(hg identify | awk '{print $1}')
            #  dir=$(basename $PWD)
            #  echo "${dir}-${commit_id}" | tee -a ../BOM
            #  popd
            #done

            ## Pull out subdirectory HG versions
            SUBREPOS=". corba jaxp jaxws langtools jdk hotspot nashorn"

            echo BOM for $(hg paths default) > BOM
            echo -e Subdir\\tHash\\t\\tTag\\tTag hash >> BOM
            for x in $SUBREPOS; do
                echo -e $x\\t$(cd $x; hg head --template '{node|short}\t' tip; hg tags --template="{tag}\t{node|short}\n" | grep -ve '^tip' | head -n1) >>BOM
            done

            cp BOM $WORKSPACE/out

            popd

            : ${YEAR:=$(date +%Y)}
            : ${DAY_OF_YEAR:=$(date +%j)}

            : ${YEAR_YESTERDAY:=$YEAR}
            : ${DAY_OF_YEAR_YESTERDAY:=$((10#$DAY_OF_YEAR - 1))}

            echo "YEAR=${YEAR}" >dates.prop
            echo "DAY_OF_YEAR=${DAY_OF_YEAR}" >>dates.prop

            echo "export YEAR=${YEAR}" > out/build-date.sh
            echo "export DAY_OF_YEAR=${DAY_OF_YEAR}" >> out/build-date.sh

            tar --exclude=.hg -acf out/jdk8u.tar.gz jdk8u
    publishers:
        - archive:
            artifacts: 'out/jdk8u.tar.gz, out/build-date.sh, out/BOM'
        - fingerprint:
            files: 'out/*'
            record-artifacts: true
        - trigger-parameterized-builds:
            - project: jdk8-build-and-test
              condition: SUCCESS
              property-file: dates.prop
