- job:
    name: tcwg-check-ci-jobs-vs-yaml
    project-type: freestyle
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            everyone-flat:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 30
    parameters:
      - string:
          name: job_subset
          default: "tcwg"
          description: 'Check only the jobs that are containing this pattern'
    disabled: false
    node: tcwg-coordinator
    display-name: 'TCWG Check CI Jobs synchro versus configs.git'
    concurrent: false
    triggers:
      - timed: '@daily'
    wrappers:
      - timestamps
      - ssh-agent-credentials:
          # tcwg-buildslave user id
          users:
              - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
      - workspace-cleanup
    builders:
        - shell: |
            #!/bin/bash

            set -euf -o pipefail

            rm -rf artifacts
            mkdir -p artifacts

            rm -rf configs jenkins-scripts
            git clone --depth 1 --single-branch \
              https://git.linaro.org/ci/job/configs.git
            git clone --depth 1 --single-branch \
              https://gitlab.com/LinaroLtd/tcwg/jenkins-scripts.git

            ./jenkins-scripts/docker-run.sh -- \
            ./configs/tcwg-check-ci-jobs-vs-yaml/tcwg-check-ci-jobs-vs-yaml.sh \
                --job_subset "$job_subset" \
                --config_dir "." \
                --result_dir "./artifacts" |& tee artifacts/check_ci_sync_summary.txt

    publishers:
        - email-ext:
            recipients: 'maxim.kuvyrkov@linaro.org, laurent.alfonsi@linaro.org'
            content-type: text
            body: |
              ${FILE,path="artifacts/check_ci_sync_summary.txt"}
            failure: true
            aborted: true
        - archive:
            artifacts: 'artifacts/**'
            latest-only: false
