########################
# Job configuration for joid
########################
- project:

    name: 'joid'

    project: '{name}'

    installer: '{name}'

#--------------------------------
# BRANCH ANCHORS
#--------------------------------
    master: &master
        stream: master
        branch: '{stream}'
        disabled: false
        gs-pathname: ''
    colorado: &colorado
        stream: colorado
        branch: 'stable/{stream}'
        disabled: false
        gs-pathname: '/{stream}'
#--------------------------------
# POD, INSTALLER, AND BRANCH MAPPING
#--------------------------------
#        CI PODs
#--------------------------------
    pod:
        - baremetal:
            slave-label: joid-baremetal
            <<: *master
        - virtual:
            slave-label: joid-virtual
            <<: *master
        - baremetal:
            slave-label: joid-baremetal
            <<: *colorado
        - virtual:
            slave-label: joid-virtual
            <<: *colorado
#--------------------------------
#        None-CI PODs
#--------------------------------
        - orange-pod1:
            slave-label: orange-pod1
            <<: *master
#--------------------------------
# scenarios
#--------------------------------
    scenario:
        - 'os-nosdn-nofeature-noha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-nosdn-nofeature-ha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-nosdn-lxd-ha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-nosdn-lxd-noha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-odl_l2-nofeature-ha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-onos-nofeature-ha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-odl_l2-nofeature-noha':
            auto-trigger-name: 'daily-trigger-disabled'
        - 'os-onos-nofeature-noha':
            auto-trigger-name: 'daily-trigger-disabled'
        - 'os-onos-sfc-ha':
            auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger'
        - 'os-ocl-nofeature-ha':
            auto-trigger-name: 'daily-trigger-disabled'
        - 'os-ocl-nofeature-noha':
            auto-trigger-name: 'daily-trigger-disabled'

    jobs:
        - 'joid-{scenario}-{pod}-daily-{stream}'
        - 'joid-deploy-{pod}-daily-{stream}'

########################
# job templates
########################
- job-template:
    name: 'joid-{scenario}-{pod}-daily-{stream}'

    disabled: '{obj:disabled}'

    concurrent: false

    properties:
        - throttle:
            enabled: true
            max-total: 4
            max-per-node: 1
            option: 'project'
        - build-blocker:
            use-build-blocker: true
            blocking-jobs:
                - 'joid-os-.*?-{pod}-daily-.*'
            block-level: 'NODE'

    wrappers:
        - build-name:
            name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO'

    triggers:
        - '{auto-trigger-name}'

    parameters:
        - project-parameter:
            project: '{project}'
        - '{installer}-defaults'
        - '{slave-label}-defaults':
            installer: '{installer}'
        - string:
            name: DEPLOY_SCENARIO
            default: '{scenario}'

    builders:
        - description-setter:
            description: "POD: $NODE_NAME"
        - trigger-builds:
            - project: 'joid-deploy-{pod}-daily-{stream}'
              current-parameters: true
              predefined-parameters:
                DEPLOY_SCENARIO={scenario}
              same-node: true
              block: true
        - trigger-builds:
            - project: 'functest-joid-{pod}-daily-{stream}'
              current-parameters: false
              predefined-parameters:
                DEPLOY_SCENARIO={scenario}
              block: true
              same-node: true
              block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
            - project: 'yardstick-joid-{pod}-daily-{stream}'
              current-parameters: false
              predefined-parameters:
                DEPLOY_SCENARIO={scenario}
              block: true
              same-node: true
              block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'

- job-template:
    name: 'joid-deploy-{pod}-daily-{stream}'

    disabled: '{obj:disabled}'

    concurrent: true

    properties:
        - throttle:
            enabled: true
            max-total: 4
            max-per-node: 1
            option: 'project'
        - build-blocker:
            use-build-blocker: true
            blocking-jobs:
                - 'joid-deploy-{pod}-daily-.*'
            block-level: 'NODE'

    wrappers:
        - build-name:
            name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO'
        - timeout:
            timeout: 180
            fail: true

    parameters:
        - project-parameter:
            project: '{project}'
        - '{installer}-defaults'
        - '{slave-label}-defaults':
            installer: '{installer}'
        - string:
            name: DEPLOY_SCENARIO
            default: 'os-odl_l2-nofeature-ha'

    scm:
        - git-scm:
            credentials-id: '{ssh-credentials}'
            refspec: ''
            branch: '{branch}'

    builders:
        - description-setter:
            description: "POD: $NODE_NAME"
        - 'builder-macro'
########################
# builder macros
########################
- builder:
    name: 'builder-macro'
    builders:
        - shell: |
            #!/bin/bash
            echo "Running $INSTALLER_TYPE with controller $SDN_CONTROLLER"
            echo
            echo "------ First Executing clean.sh ------"
            cd $WORKSPACE/ci
            ./clean.sh
        - shell:
            !include-raw: ./joid-deploy.sh

########################
# trigger macros
########################
# os-nosdn-nofeature-ha trigger - branch: master
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-baremetal-master-trigger'
    triggers:
        - timed: '5 2 * * *'
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-nosdn-nofeature-ha trigger - branch: colorado
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 2 * * *'
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-nofeature-ha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-odl_l2-nofeature-ha trigger - branch: master
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-baremetal-master-trigger'
    triggers:
        - timed: '5 7 * * *'
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-odl_l2-nofeature-ha trigger - branch: colorado
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 7 * * *'
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-odl_l2-nofeature-ha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-onos-nofeature-ha trigger - branch: master
- trigger:
    name: 'joid-os-onos-nofeature-ha-baremetal-master-trigger'
    triggers:
        - timed: '5 12 * * *'
- trigger:
    name: 'joid-os-onos-nofeature-ha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-onos-nofeature-ha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-onos-nofeature-ha trigger - branch: colorado
- trigger:
    name: 'joid-os-onos-nofeature-ha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 12 * * *'
- trigger:
    name: 'joid-os-onos-nofeature-ha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-onos-nofeature-ha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-onos-sfc-ha trigger - branch: master
- trigger:
    name: 'joid-os-onos-sfc-ha-baremetal-master-trigger'
    triggers:
        - timed: '5 17 * * *'
- trigger:
    name: 'joid-os-onos-sfc-ha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-onos-sfc-ha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-onos-sfc-ha trigger - branch: colorado
- trigger:
    name: 'joid-os-onos-sfc-ha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 17 * * *'
- trigger:
    name: 'joid-os-onos-sfc-ha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-onos-sfc-ha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-nosdn-lxd-noha trigger - branch: master
- trigger:
    name: 'joid-os-nosdn-lxd-noha-baremetal-master-trigger'
    triggers:
        - timed: '5 22 * * *'
- trigger:
    name: 'joid-os-nosdn-lxd-noha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-lxd-noha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-nosdn-lxd-noha trigger - branch: colorado
- trigger:
    name: 'joid-os-nosdn-lxd-noha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 22 * * *'
- trigger:
    name: 'joid-os-nosdn-lxd-noha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-lxd-noha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-nosdn-lxd-ha trigger - branch: master
- trigger:
    name: 'joid-os-nosdn-lxd-ha-baremetal-master-trigger'
    triggers:
        - timed: '5 10 * * *'
- trigger:
    name: 'joid-os-nosdn-lxd-ha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-lxd-ha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-nosdn-lxd-ha trigger - branch: colorado
- trigger:
    name: 'joid-os-nosdn-lxd-ha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 10 * * *'
- trigger:
    name: 'joid-os-nosdn-lxd-ha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-lxd-ha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''
# os-nosdn-nofeature-noha trigger - branch: master
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-baremetal-master-trigger'
    triggers:
        - timed: '5 4 * * *'
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-virtual-master-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-orange-pod1-master-trigger'
    triggers:
        - timed: ''
# os-nosdn-nofeature-noha trigger - branch: colorado
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-baremetal-colorado-trigger'
    triggers:
        - timed: '0 4 * * *'
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-virtual-colorado-trigger'
    triggers:
        - timed: ''
- trigger:
    name: 'joid-os-nosdn-nofeature-noha-orange-pod1-colorado-trigger'
    triggers:
        - timed: ''