- project:
    name: trigger-lt-qcom-linux

    # defaults
    repo: 'https://git.codelinaro.org/linaro/qcomlt/kernel.git'
    configs_arm64: 'defconfig distro.config'
    configs_arm: 'multi_v7_defconfig distro.config'
    branch: 'release/qcomlt-{version}'
    trigger:
      - 'refs/heads/release/qcomlt-{version}'
    refspec: '+refs/heads/*:refs/remotes/origin/*'
    debian: ''

    jobs:
        - 'trigger-lt-qcom-linux-{version}':
            version: '5.7'
            flavor: 'release'
            debian: 'linux'
        - 'trigger-lt-qcom-linux-{version}':
            version: '5.9'
            flavor: 'release'
            debian: 'linux'
        - 'trigger-lt-qcom-linux-{version}':
            version: '5.10'
            flavor: 'release'
            debian: 'linux'
        - 'trigger-lt-qcom-linux-{version}':
            version: '5.13'
            flavor: 'release'
            debian: 'linux'
        - 'trigger-lt-qcom-linux-{version}':
            version: '5.15'
            flavor: 'release'
            debian: 'linux'
        - 'trigger-lt-qcom-linux-{version}':
            branch: 'integration-linux-qcomlt'
            trigger:
              - 'refs/heads/{branch}'
            version: 'integration'
            flavor: 'integration'
        - 'trigger-lt-qcom-linux-{version}':
            branch: 'master'
            trigger:
              - 'refs/tags/v4.*'
              - 'refs/tags/v5.*'
              - 'refs/tags/v6.*'
            refspec: '+refs/heads/master:refs/remotes/origin/master +refs/tags/*:refs/remotes/origin/tags/*'
            version: 'mainline'
            repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git'
            configs_arm64: 'defconfig'
            configs_arm: 'multi_v7_defconfig'
            flavor: 'mainline'

- job-template:
    name: 'trigger-lt-qcom-linux-{version}'
    project-type: freestyle
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
                - job-workspace
            linaro-qualcomm-ci:
                - job-read
                - job-extended-read
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 30
            artifact-num-to-keep: 1
    disabled: false
    node: triggers
    display-name: 'Trigger for Qualcomm LT kernel {branch} branch'
    scm:
        - git:
            url: '{repo}'
            refspec: '{refspec}'
            name: origin
            branches: '{trigger}'
            skip-tag: true
            shallow-clone: false
            wipe-workspace: false
    triggers:
        - pollscm:
            cron: 'H/5 * * * *'
    wrappers:
        - timestamps
        - build-name:
            name: '#${{BUILD_NUMBER}}-${{GIT_REVISION,length=8}}'
    builders:
        - shell: |
            #!/bin/bash -e

            # bring in stable and mainline tags
            git fetch --tags https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git
            git fetch --tags https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git

            echo KERNEL_VERSION=$(make kernelversion) > qcomlt_parameters
            echo KERNEL_DESCRIBE=$(git describe --always) >> qcomlt_parameters
            echo KERNEL_REPO_URL={repo} >> qcomlt_parameters
            if [ "{flavor}" = "mainline" ]; then
              echo KERNEL_BRANCH=master >> qcomlt_parameters
            else
              echo KERNEL_BRANCH=$(echo $GIT_BRANCH | sed  's|origin/||') >> qcomlt_parameters
            fi
            echo KERNEL_FLAVOR={flavor} >> qcomlt_parameters
            echo KERNEL_DEBIAN={debian} >> qcomlt_parameters
            echo TARGET_REPO=linaro-overlay-sid >> qcomlt_parameters
            echo KDEB_CHANGELOG_DIST=unstable >> qcomlt_parameters

            echo KERNEL_CONFIGS_arm={configs_arm} >> qcomlt_parameters
            echo KERNEL_CONFIGS_arm64={configs_arm64} >> qcomlt_parameters
            cat qcomlt_parameters
    publishers:
        - trigger-parameterized-builds:
            - project:
                - 'lt-qcom-linux'
              condition: SUCCESS
              property-file: qcomlt_parameters
        - email-ext:
            recipients: 'leonardo.sandoval@linaro.org dmitry.baryshkov@linaro.org'
            failure: true
            still-failing: true
