- project:
    name: gerrit-dahdi-linux-stable
    type: stable
    repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git'
    linux-ver:
      - "linux-4.19.y"
      - "linux-5.10.y"
      - "linux-6.1.y"
      - "linux-rolling-stable"
    jobs:
      - 'gerrit-dahdi-linux-{type}-{linux-ver}'

- project:
    name: gerrit-dahdi-linux-torvalds
    type: torvalds
    repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git'
    linux-ver:
      - "master"
    jobs:
      - 'gerrit-dahdi-linux-{type}-{linux-ver}'


- job-template:
    name: 'gerrit-dahdi-linux-{type}-{linux-ver}'
    project-type: freestyle
    node: osmocom-gerrit
    # These jobs need an entire linux tree. We try to avoid cloning it more
    # often than necessary, therefore we keep the workspace directory between
    # job runs. Jenkins creates a new workspace for each concurrent job, which
    # ends up consuming a lot of disk space so we disable it here. Besides disk
    # space considerations, this job would run fine concurrently.
    concurrent: false
    retry-count: 0 # scm checkout
    properties:
      - build-discarder:
          days-to-keep: 30
          num-to-keep: 120
    description: |
      Pending gerrit code reviews of
      <a href="https://gerrit.osmocom.org/#/q/status:open+project:dahdi-linux">dahdi-linux</a>
      built against linux {linux-ver}
      (<a href="https://osmocom.org/issues/5407">OS#5407</a>)
      <br/><br/>
      <b>Auto-generated using Jenkins Job Builder. DO NOT EDIT MANUALLY!</b>

    scm:
      # Let jenkins clone the big linux repository and keep it between builds
      # (wipe-workspace is false). Clone dahdi-linux with code from gerrit in
      # the shell part below.
      - git:
         basedir: 'linux'
         url: '{repo}'
         branches:
           - '{linux-ver}'
         refspec: '{linux-ver}'
         shallow-clone: true
         wipe-workspace: false
         clean:
          before: true

    triggers:
      - gerrit:
          trigger-on:
            - patchset-created-event:
                exclude-drafts: true
                exclude-no-code-change: true
          projects:
            - project-compare-type: 'PLAIN'
              project-pattern: 'dahdi-linux'
              branches:
                - branch-compare-type: 'ANT'
                  branch-pattern: '**'
          skip-vote:
              successful: false
              failed: false
              unstable: false
              notbuilt: false
          silent: false
          escape-quotes: false
          server-name: gerrit.osmocom.org

    builders:
      - shell: |
          git -C linux config gc.autoDetach false
          git -C linux gc --auto

          rm -rf dahdi-linux
          git init dahdi-linux
          cd dahdi-linux
          git config advice.detachedHead false
          git fetch \
            --depth=1 \
            https://gerrit.osmocom.org/dahdi-linux \
            "$GERRIT_REFSPEC"
          git checkout FETCH_HEAD
          cd ..

          docker run \
            --rm=true \
            -e "KSRC=/linux" \
            -v "$PWD/dahdi-linux:/build" \
            -v "$PWD/linux:/linux" \
            "$USER/debian-bookworm-build" \
            timeout 10m su build -c /build/contrib/jenkins.sh

    publishers:
       - warnings:
           console-log-parsers:
             - 'GNU C Compiler 4 (gcc)'
           resolve-relative-paths: true

# vim: expandtab tabstop=2 shiftwidth=2