- project:
    name: ovsnfv

    project: '{name}'

    jobs:
        - 'ovsnfv-verify-{stream}'
        - 'ovsnfv-merge-{stream}'
        - 'ovsnfv-daily-{stream}'

    stream:
        - master:
            branch: '{stream}'
            gs-pathname: ''
        - brahmaputra:
            branch: 'stable/{stream}'
            gs-pathname: '/{stream}'

- job-template:
    name: 'ovsnfv-verify-{stream}'

    parameters:
        - project-parameter:
            project: '{project}'
        - gerrit-parameter:
            branch: '{branch}'
        - 'intel-build2-defaults'
        - string:
            name: GS_URL
            default: '$GS_BASE{gs-pathname}'
            description: "Directory where the build artifact will be located upon the completion of the build."

    scm:
        - gerrit-trigger-scm:
            credentials-id: '{ssh-credentials}'
            refspec: '$GERRIT_REFSPEC'
            choosing-strategy: 'gerrit'

    triggers:
        - gerrit:
            trigger-on:
                - patchset-created-event:
                    exclude-drafts: 'false'
                    exclude-trivial-rebase: 'false'
                    exclude-no-code-change: 'false'
                - 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: '{project}'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'build/**'
                  - compare-type: ANT
                    pattern: 'ci/**'

    builders:
        - build-rpms

- job-template:
    name: 'ovsnfv-merge-{stream}'

    parameters:
        - project-parameter:
            project: '{project}'
        - gerrit-parameter:
            branch: '{branch}'
        - 'intel-build2-defaults'
        - string:
            name: GS_URL
            default: '$GS_BASE{gs-pathname}'
            description: "Directory where the build artifact will be located upon the completion of the build."

    scm:
        - gerrit-trigger-scm:
            credentials-id: '{ssh-credentials}'
            refspec: ''
            choosing-strategy: 'default'

    wrappers:
        - timeout:
            timeout: 24
            fail: true

    triggers:
        - gerrit:
            trigger-on:
                - change-merged-event
                - comment-added-contains-event:
                    comment-contains-value: 'remerge'
            projects:
              - project-compare-type: 'ANT'
                project-pattern: '{project}'
                branches:
                  - branch-compare-type: 'ANT'
                    branch-pattern: '**/{branch}'
                file-paths:
                  - compare-type: ANT
                    pattern: 'build/**'
                  - compare-type: ANT
                    pattern: 'ci/**'

    builders:
        - build-rpms

- job-template:
    name: 'ovsnfv-daily-{stream}'

    parameters:
        - project-parameter:
            project: '{project}'
        - 'intel-build2-defaults'
        - string:
            name: GS_URL
            default: '$GS_BASE{gs-pathname}'
            description: "Directory where the build artifact will be located upon the completion of the build."

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

    wrappers:
        - timeout:
            timeout: 24
            fail: true

    triggers:
        - timed: '@midnight'

    builders:
        - build-rpms

    publishers:
        - email:
            recipients: therbert@redhat.com mark.d.gray@intel.com billy.o.mahony@intel.com

- builder:
    name: build-rpms
    builders:
        - shell: |
            #!/bin/bash
            set -o errexit
            set -o nounset
            set -o pipefail

            cd $WORKSPACE/ci
            ./build.sh