---
- project:
    name: 'build-kernels'
    jobs:
      - 'build-kernel-{linux-repo}'
    linux-repo:
      - torvalds:
          linux-branch: "master"
      - net-next:
          linux-branch: "main"

- job-template:
    name: 'build-kernel-{linux-repo}'
    project-type: freestyle
    description: |
        Build a <code>{linux-repo}/{linux-branch}</code> kernel to be used with
        osmo-ttcn3-hacks for running SUT in QEMU
    node: "linux-shallow-clone"
    concurrent: true
    parameters:
      - string:
          name: EMAIL_NOTIFICATIONS
          description: For failed build notifications, set to empty to disable
          default: 'jenkins-notifications@lists.osmocom.org'
      - string:
          name: BRANCH_CI
          description: Branch of osmo-ci.git (has scripts/kernel/build.sh)
          default: 'master'
    builders:
      - shell: |-
          set -e
          IMAGE="osmocom-build/debian-bookworm-osmo-ttcn3-testenv"
          podman pull "registry.osmocom.org/$IMAGE"
          scripts/kernel/build.sh ~/linux.git {linux-repo}-{linux-branch}
    scm:
      - git:
          branches:
            - '$BRANCH_CI'
          url: "https://gerrit.osmocom.org/osmo-ci"
          git-config-name: 'Jenkins Builder'
          git-config-email: 'jenkins@osmocom.org'
          wipe-workspace: true
    triggers:
      - timed: "H 23 * * *"
    publishers:
      - email:
          notify-every-unstable-build: true
          recipients: '$EMAIL_NOTIFICATIONS'
          send-to-individuals: false
      - archive:
          allow-empty: false
          artifacts: output/**/*
          case-sensitive: true
          default-excludes: true
          fingerprint: false
          only-if-success: false
    properties:
    - build-discarder:
        num-to-keep: 10
    wrappers:
    - ansicolor:
        colormap: xterm

- job:
    name: 'build-kernel-none'
    project-type: freestyle
    defaults: global
    description: |
      Dummy job to allow specifying "none" as kernel in
      <a href="https://gitea.osmocom.org/osmocom/osmo-ci/src/branch/master/jobs/ttcn3-testsuites-testenv.yml">ttcn3-testsuites-testenv.yml</a>.
    node: "osmocom-master"
    builders:
      - shell: |-
          mkdir output
          echo "dummy from build-kernel-none jenkins job" > output/linux
    publishers:
      - archive:
          allow-empty: false
          artifacts: output/**/*
          case-sensitive: true
          default-excludes: true
          fingerprint: false
          only-if-success: false
    properties:
    - build-discarder:
        num-to-keep: 10
