- project:
    name: apex
    jobs:
        - 'apex-verify-{stream}'
        - 'apex-verify-gate-{stream}'
        - 'apex-verify-unit-tests-{stream}'
        - 'apex-runner-{platform}-{scenario}-{stream}'
        - 'apex-runner-cperf-{stream}'
        - 'apex-build-{stream}'
        - 'apex-deploy-virtual-{scenario}-{stream}'
        - 'apex-deploy-baremetal-{scenario}-{stream}'
        - 'apex-daily-{stream}'
        - 'apex-csit-promote-daily-{stream}'
        - 'apex-fdio-promote-daily-{stream}'

    # stream:    branch with - in place of / (eg. stable-arno)
    # branch:    branch (eg. stable/arno)
    stream:
        - master:
            branch: 'master'
            gs-pathname: ''
            slave: 'lf-pod1'
            verify-slave: 'apex-verify-master'
            daily-slave: 'apex-daily-master'
        - danube:
            branch: 'stable/danube'
            gs-pathname: '/danube'
            slave: 'lf-pod1'
            verify-slave: 'apex-verify-danube'
            daily-slave: 'apex-daily-danube'

    project: 'apex'

    scenario:
         - 'os-nosdn-nofeature-noha'
         - 'os-nosdn-nofeature-ha'
         - 'os-nosdn-nofeature-ha-ipv6'
         - 'os-nosdn-ovs-noha'
         - 'os-nosdn-fdio-noha'
         - 'os-nosdn-fdio-ha'
         - 'os-nosdn-kvm-ha'
         - 'os-nosdn-kvm-noha'
         - 'os-odl_l2-fdio-noha'
         - 'os-odl_l2-fdio-ha'
         - 'os-odl_l2-netvirt_gbp_fdio-noha'
         - 'os-odl_l2-sfc-noha'
         - 'os-odl_l3-nofeature-ha'
         - 'os-odl-bgpvpn-ha'
         - 'os-odl-gluon-noha'
         - 'os-odl_l3-fdio-noha'
         - 'os-odl_l3-fdio-ha'
         - 'os-odl_l3-fdio_dvr-noha'
         - 'os-odl_l3-fdio_dvr-ha'
         - 'os-odl_l3-csit-noha'
         - 'os-odl_l3-nofeature-noha'
         - 'os-onos-nofeature-ha'
         - 'gate'

    platform:
         - 'baremetal'
         - 'virtual'

# Unit Test
- job-template:
    name: 'apex-verify-unit-tests-{stream}'

    node: '{verify-slave}'

    concurrent: true

    parameters:
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm-gerrit

    triggers:
        - gerrit:
            server-name: 'gerrit.opnfv.org'
            trigger-on:
                - patchset-created-event:
                    exclude-drafts: 'false'
                    exclude-trivial-rebase: 'false'
                    exclude-no-code-change: 'true'
                - draft-published-event
                - comment-added-contains-event:
                    comment-contains-value: 'recheck'
                - comment-added-contains-event:
                    comment-contains-value: 'reverify'
            projects:
              - project-compare-type: 'ANT'
                project-pattern: 'apex'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'tests/**'
    properties:
        - logrotate-default
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - 'apex-unit-test'

# Verify
- job-template:
    name: 'apex-verify-{stream}'

    node: '{verify-slave}'

    concurrent: true

    parameters:
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm-gerrit

    triggers:
        - gerrit:
            server-name: 'gerrit.opnfv.org'
            trigger-on:
                - patchset-created-event:
                    exclude-drafts: 'false'
                    exclude-trivial-rebase: 'false'
                    exclude-no-code-change: 'true'
                - draft-published-event
                - comment-added-contains-event:
                    comment-contains-value: 'recheck'
                - comment-added-contains-event:
                    comment-contains-value: 'reverify'
            projects:
              - project-compare-type: 'ANT'
                project-pattern: 'apex'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'ci/**'
                  - compare-type: ANT
                    pattern: 'build/**'
                  - compare-type: ANT
                    pattern: 'lib/**'
                  - compare-type: ANT
                    pattern: 'config/**'

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-daily.*'
                - 'apex-deploy.*'
                - 'apex-build.*'
                - 'apex-runner.*'
                - 'apex-verify.*'
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - 'apex-unit-test'
        - 'apex-build'
        - trigger-builds:
          - project: 'apex-deploy-virtual-os-odl_l3-nofeature-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-verify-{stream}
              OPNFV_CLEAN=yes
            git-revision: false
            block: true
            same-node: true
        - trigger-builds:
          - project: 'functest-apex-{verify-slave}-suite-{stream}'
            predefined-parameters: |
              DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
              FUNCTEST_SUITE_NAME=healthcheck
            block: true
            same-node: true
        - 'apex-workspace-cleanup'

# Verify Scenario Gate
- job-template:
    name: 'apex-verify-gate-{stream}'

    node: '{verify-slave}'

    concurrent: true

    parameters:
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm-gerrit

    triggers:
        - gerrit:
            server-name: 'gerrit.opnfv.org'
            trigger-on:
                - comment-added-contains-event:
                    comment-contains-value: '^Patch Set [0-9]+: Code-Review\+2.*start-gate-scenario:.*'
            projects:
              - project-compare-type: 'ANT'
                project-pattern: 'apex'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'ci/**'
                  - compare-type: ANT
                    pattern: 'build/**'
                  - compare-type: ANT
                    pattern: 'lib/**'
                  - compare-type: ANT
                    pattern: 'config/**'

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-daily.*'
                - 'apex-deploy.*'
                - 'apex-build.*'
                - 'apex-runner.*'
                - 'apex-verify.*'
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - 'apex-build'
        - trigger-builds:
          - project: 'apex-deploy-virtual-gate-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-verify-gate-{stream}
              OPNFV_CLEAN=yes
            current-parameters: true
            git-revision: false
            block: true
            same-node: true
        - trigger-builds:
          - project: 'functest-apex-{verify-slave}-suite-{stream}'
            predefined-parameters: |
              DEPLOY_SCENARIO=os-nosdn-nofeature-ha
              FUNCTEST_SUITE_NAME=healthcheck
            block: true
            same-node: true
        - 'apex-workspace-cleanup'

- job-template:
    name: 'apex-runner-{platform}-{scenario}-{stream}'

    # runner jobs for deploying manually

    node: '{slave}'

    disabled: false

    parameters:
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            blocking-jobs:
                - 'apex-daily.*'
                - 'apex-verify.*'
                - 'apex-.*-promote.*'

    builders:
        - trigger-builds:
          - project: 'apex-deploy-{platform}-{scenario}-{stream}'
            predefined-parameters:
              OPNFV_CLEAN=yes
            git-revision: false
            block: true
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO={scenario}
            block: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'functest-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO={scenario}
            block: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'

- job-template:
    name: 'apex-runner-cperf-{stream}'

    # runner cperf job

    node: 'intel-pod2'

    disabled: false

    parameters:
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: false
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-deploy.*'
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl_l3-nofeature-noha-{stream}'
            predefined-parameters:
              OPNFV_CLEAN=yes
            git-revision: false
            block: true
            same-node: true
        - trigger-builds:
          - project: 'cperf-apex-intel-pod2-daily-master'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l3-nofeature-noha
            block: true
            same-node: true

- job-template:
    name: 'apex-build-{stream}'

    # Job template for builds
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{daily-slave}'

    disabled: false

    concurrent: true

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from parameters macro."

    scm:
        - git-scm

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-deploy.*'
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - 'apex-build'
        - trigger-builds:
          - project: 'apex-deploy-virtual-os-nosdn-nofeature-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: false
            same-node: true
            block: true
        - 'apex-upload-artifact'

- job-template:
    name: 'apex-deploy-virtual-{scenario}-{stream}'

    # Job template for virtual deployment
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{slave}'

    concurrent: true

    disabled: false

    scm:
        - git-scm

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - string:
            name: DEPLOY_SCENARIO
            default: '{scenario}'
            description: "Scenario to deploy with."
        - string:
            name: OPNFV_CLEAN
            default: 'no'
            description: "Use yes in lower case to invoke clean. Indicates if the deploy environment should be cleaned before deployment"

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-deploy.*'
        - throttle:
            max-per-node: 1
            max-total: 10
            option: 'project'

    builders:
        - 'apex-deploy'
        - 'apex-workspace-cleanup'

- job-template:
    name: 'apex-deploy-baremetal-{scenario}-{stream}'

    # Job template for baremetal deployment
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{slave}'

    disabled: false

    scm:
        - git-scm

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'
        - string:
            name: DEPLOY_SCENARIO
            default: '{scenario}'
            description: "Scenario to deploy with."

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-verify.*'
                - 'apex-deploy.*'
                - 'apex-build.*'


    builders:
        - 'apex-deploy'
        - 'apex-workspace-cleanup'

# Daily
- job-template:
    name: 'apex-daily-{stream}'

    # Job template for daily build
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{daily-slave}'

    disabled: false

    scm:
        - git-scm

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'

    properties:
        - logrotate-default
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-verify.*'
                - 'apex-deploy.*'
                - 'apex-build.*'
                - 'apex-runner.*'
                - 'apex-.*-promote.*'

    triggers:
        - 'apex-{stream}'

    builders:
        - trigger-builds:
          - project: 'apex-build-{stream}'
            git-revision: true
            current-parameters: true
            same-node: true
            block: true
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-nosdn-nofeature-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-nofeature-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-nofeature-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        # 1.dovetail only master by now, not sync with A/B/C branches
        # 2.here the stream means the SUT stream, dovetail stream is defined in its own job
        # 3.only debug testsuite here(includes basic testcase,
        #   i.e. one tempest smoke ipv6, two vping from functest)
        # 4.not used for release criteria or compliance,
        #   only to debug the dovetail tool bugs with apex
        #- trigger-builds:
        #    - project: 'dovetail-apex-{slave}-debug-{stream}'
        #      current-parameters: false
        #      predefined-parameters:
        #        DEPLOY_SCENARIO=os-nosdn-nofeature-ha
        #      block: true
        #      same-node: true
        #      block-thresholds:
        #        build-step-failure-threshold: 'never'
        #        failure-threshold: 'never'
        #        unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl_l3-nofeature-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl-bgpvpn-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl-bgpvpn-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl-bgpvpn-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl-gluon-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl-gluon-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl-gluon-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl_l2-fdio-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l2-fdio-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l2-fdio-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl_l2-fdio-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l2-fdio-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l2-fdio-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-nosdn-kvm-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-kvm-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-kvm-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-odl_l3-fdio-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l3-fdio-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-odl_l3-fdio-noha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'apex-deploy-baremetal-os-nosdn-fdio-ha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-build-{stream}/.build
              OPNFV_CLEAN=yes
            git-revision: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
            block: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-fdio-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'
        - trigger-builds:
          - project: 'yardstick-apex-{slave}-daily-{stream}'
            predefined-parameters:
              DEPLOY_SCENARIO=os-nosdn-fdio-ha
            block: true
            same-node: true
            block-thresholds:
                build-step-failure-threshold: 'never'
                failure-threshold: 'never'
                unstable-threshold: 'FAILURE'

# CSIT promote
- job-template:
    name: 'apex-csit-promote-daily-{stream}'

    # Job template for promoting CSIT Snapshots
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{daily-slave}'

    disabled: false

    scm:
        - git-scm

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'

    properties:
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-verify.*'
                - 'apex-deploy.*'
                - 'apex-build.*'
                - 'apex-runner.*'
                - 'apex-daily.*'

    triggers:
        - timed: '0 12 * * 0'

    builders:
        - 'apex-build'
        - trigger-builds:
          - project: 'apex-deploy-virtual-os-odl_l3-csit-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-csit-promote-daily-{stream}
              OPNFV_CLEAN=yes
            git-revision: false
            block: true
            same-node: true
        - trigger-builds:
          - project: 'functest-apex-{daily-slave}-suite-{stream}'
            predefined-parameters: |
              DEPLOY_SCENARIO=os-odl_l3-nofeature-noha
              FUNCTEST_SUITE_NAME=tempest_smoke_serial
            block: true
            same-node: true
        - shell:
            !include-raw-escape: ./apex-snapshot-create.sh
        - shell:
            !include-raw-escape: ./apex-upload-artifact.sh

# FDIO promote
- job-template:
    name: 'apex-fdio-promote-daily-{stream}'

    # Job template for promoting CSIT Snapshots
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: '{daily-slave}'

    disabled: false

    scm:
        - git-scm

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'

    properties:
        - build-blocker:
            use-build-blocker: true
            block-level: 'NODE'
            blocking-jobs:
                - 'apex-verify.*'
                - 'apex-deploy.*'
                - 'apex-build.*'
                - 'apex-runner.*'
                - 'apex-daily.*'

    builders:
        - 'apex-build'
        - trigger-builds:
          - project: 'apex-deploy-virtual-os-odl_l2-fdio-noha-{stream}'
            predefined-parameters: |
              BUILD_DIRECTORY=apex-fdio-promote-daily-{stream}
              OPNFV_CLEAN=yes
            git-revision: false
            block: true
            same-node: true
        - shell:
            !include-raw-escape: ./apex-snapshot-create.sh
        - shell:
            !include-raw-escape: ./apex-upload-artifact.sh

- job-template:
    name: 'apex-gs-clean-{stream}'

    # Job template for clean
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    node: '{slave}'

    disabled: false

    parameters:
        - project-parameter:
            project: '{project}'
            branch: '{branch}'
        - apex-parameter:
            gs-pathname: '{gs-pathname}'

    builders:
        - 'apex-gs-clean'

    triggers:
        - 'apex-gs-clean-{stream}'


########################
# parameter macros
########################
- parameter:
    name: apex-parameter
    parameters:
        - string:
            name: ARTIFACT_NAME
            default: 'latest'
            description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
        - string:
            name: ARTIFACT_VERSION
            default: 'daily'
            description: "Artifact version type"
        - string:
            name: BUILD_DIRECTORY
            default: $WORKSPACE/build
            description: "Directory where the build artifact will be located upon the completion of the build."
        - string:
            name: CACHE_DIRECTORY
            default: $HOME/opnfv/cache{gs-pathname}
            description: "Directory where the cache to be used during the build is located."
        - string:
            name: GIT_BASE
            default: https://gerrit.opnfv.org/gerrit/$PROJECT
            description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
        - string:
            name: GS_PATHNAME
            default: '{gs-pathname}'
            description: "Version directory where opnfv artifacts are stored in gs repository"
        - string:
            name: GS_URL
            default: artifacts.opnfv.org/$PROJECT{gs-pathname}
            description: "URL to Google Storage."

########################
# builder macros
########################
- builder:
    name: 'apex-unit-test'
    builders:
        - shell:
            !include-raw: ./apex-unit-test.sh

- builder:
    name: 'apex-build'
    builders:
        - shell:
            !include-raw: ./apex-build.sh

- builder:
    name: 'apex-workspace-cleanup'
    builders:
        - shell:
            !include-raw: ./apex-workspace-cleanup.sh

- builder:
    name: 'apex-upload-artifact'
    builders:
        - shell:
            !include-raw: ./apex-upload-artifact.sh

- builder:
    name: 'apex-gs-cleanup'
    builders:
        - shell:
            !include-raw: ./apex-gs-cleanup.sh

- builder:
    name: 'apex-deploy'
    builders:
        - shell:
            !include-raw: ./apex-deploy.sh


#######################
# trigger macros
########################
- trigger:
    name: 'apex-master'
    triggers:
        - timed: '0 3 1 1 7'
- trigger:
    name: 'apex-danube'
    triggers:
        - timed: '0 12 * * *'
- trigger:
    name: 'apex-gs-clean-{stream}'
    triggers:
        - timed: '0 2 * * *'