---
- project:
    name: 'apex-project-jobs'
    project: 'apex'

    stream:
      - master: &master
          branch: 'master'
          gs-pathname: ''
          concurrent-builds: 3
          disabled: false
      - gambia: &gambia
          branch: 'stable/{stream}'
          gs-pathname: '/{stream}'
          concurrent-builds: 3
          disabled: false
      - fraser: &fraser
          branch: 'stable/{stream}'
          gs-pathname: '/{stream}'
          concurrent-builds: 3
          disabled: false
      - euphrates: &euphrates
          branch: 'stable/euphrates'
          gs-pathname: '/euphrates'
          concurrent-builds: 3
          disabled: true
      - danube: &danube
          branch: 'stable/danube'
          gs-pathname: '/danube'
          concurrent-builds: 1
          disabled: true

    jobs:
      - 'apex-build-{stream}'
      - 'apex-verify-iso-{stream}'

# Build phase
- 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: 'apex-build-master'

    disabled: false

    concurrent: true

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

    scm:
      - git-scm-gerrit

    wrappers:
      - timeout:
          timeout: 150
          fail: true

    properties:
      - logrotate-default
      - throttle:
          max-per-node: '{concurrent-builds}'
          max-total: 10
          option: 'project'
      - build-blocker:
          use-build-blocker: true
          blocking-level: 'NODE'
          blocking-jobs:
            - 'apex-verify-iso-{stream}'

    builders:
      - 'apex-build'
      - inject:
          properties-content: ARTIFACT_TYPE=rpm
      - 'apex-upload-artifact'

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

    # Job template for builds
    #
    # Required Variables:
    #     stream:    branch with - in place of / (eg. stable)
    #     branch:    branch (eg. stable)
    node: 'apex-virtual-master'

    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
      - throttle:
          max-per-node: 1
          max-total: 10
          option: 'project'

    builders:
      - 'apex-iso-verify'
      - inject:
          properties-content: ARTIFACT_TYPE=iso
      - 'apex-upload-artifact'

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

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