---
# jobs for https://github.com/omec-project/up4

- project:
    name: up4
    project: "{name}"
    github-organization: "omec-project"
    github_pr_auth_id: "64fe2b1a-b33a-4f13-8442-ad8360434003"
    github_pr_org_list:
      - "omec-project"

    # Matrix
    up4Ctrl:
      - pfcp
      - p4rt

    jobs:
      - "up4-jobs":
          stream: "master"
          # As we run integration tests with 3 ONOS instances,
          # we need a beefy node.
          build-node: "ubuntu18.04-basebuild-8c-15g"

- job-group:
    name: "up4-jobs"
    jobs:
      - "up4-pr-verify-{up4Ctrl}"
      - "up4-postmerge-{up4Ctrl}"
      - "up4-latest-nightly-{up4Ctrl}"

- job-template:
    id: "up4-pr-verify-{up4Ctrl}"
    name: "up4-pr-verify-{up4Ctrl}"
    description: |
      Created by {id} job-template from ci-management/up4.yaml<br/>

    project-type: pipeline
    concurrent: true

    properties:
      - cord-infra-properties:
          build-days-to-keep: "15"
          artifact-num-to-keep: "-1"
      - github:
          url: "https://github.com/{github-organization}/{project}"

    parameters:
      - string:
          name: buildNode
          default: "{build-node}"
          description: "Name of the Jenkins executor node to run the job on."
      - string:
          name: sha1
          default: "origin/{stream}"
          description: "SHA string of the pull request commit to build. Populated by GitHUb Pull Request Builder."
      - string:
          name: up4Ctrl
          default: "{up4Ctrl}"
          description: "Run p4rt or pfpc -based STC scenarios: [p4rt, pfcp]"

    # Run pipeline that is checked-in in the same PR we want to verify.
    pipeline-scm:
      script-path: ".jenkins/Jenkinsfile"
      scm:
        - git:
            url: "git@github.com:{github-organization}/{project}.git"
            credentials-id: "github-onf-bot-ssh-key"
            refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
            branches:
              - "$sha1"
            submodule:
              disable: true
            shallow-clone: true

    triggers:
      - cord-infra-github-pr-trigger:
          github_pr_org_list: "{obj:github_pr_org_list}"
          github_pr_auth_id: "{github_pr_auth_id}"
          status_context: "up4-pr-verify-{up4Ctrl}"

    wrappers:
      - lf-infra-wrappers:
          build-timeout: "{build-timeout}"
          jenkins-ssh-credential: "{jenkins-ssh-credential}"
      - credentials-binding:
          - text:
              credential-id: codecov-up4
              variable: CODECOV_TOKEN

- job-template:
    id: "up4-postmerge-{up4Ctrl}"
    name: "up4-postmerge-{up4Ctrl}"
    description: |
      Created by {id} job-template from ci-management/up4.yaml<br/>

    project-type: pipeline
    concurrent: true

    properties:
      - cord-infra-properties:
          build-days-to-keep: "15"
          artifact-num-to-keep: "-1"
      - github:
          url: "https://github.com/{github-organization}/{project}"

    parameters:
      - string:
          name: buildNode
          default: "{build-node}"
          description: "Name of the Jenkins executor node to run the job on."
      - string:
          name: commitHash
          default: 'origin/{stream}'
          description: 'SHA string of the merged commit to build. Populated by Generic Webhook Trigger.'
      - string:
          name: up4Ctrl
          default: "{up4Ctrl}"
          description: "Run p4rt or pfpc -based STC scenarios: [p4rt, pfcp]"

    pipeline-scm:
      script-path: ".jenkins/Jenkinsfile"
      scm:
        - git:
            url: "git@github.com:{github-organization}/{project}.git"
            credentials-id: "github-onf-bot-ssh-key"
            refspec: "+refs/heads/*:refs/remotes/origin/*"
            branches:
              - "$commitHash"
            submodule:
              disable: true
            shallow-clone: true

    triggers:
      - cord-infra-github-pr-trigger-merge:
          project: '{project}'
      - timed: "@midnight"

    wrappers:
      - lf-infra-wrappers:
          build-timeout: "{build-timeout}"
          jenkins-ssh-credential: "{jenkins-ssh-credential}"
      - credentials-binding:
          - text:
              credential-id: codecov-up4
              variable: CODECOV_TOKEN

- job-template:
    id: "up4-latest-nightly-{up4Ctrl}"
    name: "up4-latest-nightly-{up4Ctrl}"
    description: |
      Created by {id} job-template from ci-management/up4.yaml<br/>

    project-type: pipeline
    concurrent: true

    properties:
      - cord-infra-properties:
          build-days-to-keep: "15"
          artifact-num-to-keep: "-1"
      - github:
          url: "https://github.com/{github-organization}/{project}"

    parameters:
      - string:
          name: buildNode
          default: "{build-node}"
          description: "Name of the Jenkins executor node to run the job on."
      - string:
          name: commitHash
          default: 'origin/{stream}'
          description: 'SHA string of the merged commit to build. Populated by Generic Webhook Trigger.'
      - string:
          name: up4Env
          default: 'latest'
          description: 'UP4 STC scenarios environment (stable or latest)'
      - string:
          name: up4Ctrl
          default: "{up4Ctrl}"
          description: "Run p4rt or pfpc -based STC scenarios: [p4rt, pfcp]"

    pipeline-scm:
      script-path: ".jenkins/Jenkinsfile"
      scm:
        - git:
            url: "git@github.com:{github-organization}/{project}.git"
            credentials-id: "github-onf-bot-ssh-key"
            refspec: "+refs/heads/*:refs/remotes/origin/*"
            branches:
              - "$commitHash"
            submodule:
              disable: true
            shallow-clone: true

    triggers:
      - timed: "@midnight"

    wrappers:
      - lf-infra-wrappers:
          build-timeout: "{build-timeout}"
          jenkins-ssh-credential: "{jenkins-ssh-credential}"
      - credentials-binding:
          - text:
              credential-id: codecov-up4
              variable: CODECOV_TOKEN

# [EOF]
