# Auto generated by ./tcwg/generate-yamlfiles.sh from tcwg-report-stale-rr-jobs.yaml.in and tcwg-report-stale-rr-jobs/tcwg-report-stale-rr-jobs-in_production.def. Do not edit.
#BEGIN: tcwg/default.yaml.inc
# -*- mode: Yaml -*-

- property:
    name: default-properties
    properties:
      - authorization:
          anonymous:
            - job-read
            - job-extended-read
          everyone-flat:
            - job-build
            - job-cancel
      - build-discarder:
          days-to-keep: 20

- scm:
    name: jenkins-scripts-master
    scm:
      - git:
          url: https://gitlab.com/LinaroLtd/tcwg/jenkins-scripts.git
          refspec: +refs/heads/master:refs/remotes/origin/master
          branches:
            - master
          basedir: jenkins-scripts
          skip-tag: true
          reference-repo: /home/tcwg-buildslave/snapshots-ref/jenkins-scripts.git
          wipe-workspace: false
          clean:
            before: true
          prune: true

#END:   tcwg/default.yaml.inc

- job:
    name: tcwg-report-stale-rr-jobs-in_production
    project-type: freestyle
    defaults: global
    properties:
      - default-properties
    parameters:
      - string:
          name: days
          default: 8
          description: 'List jobs with no successful run in DAYS'
      - string:
          name: days_per_project_extra_params
          default: ==days_per_project[tcwg_flang] 1 ==days_per_project[tcwg_chromium] 360
          description: 'For the specified projects, use this DAYS value'
    disabled: false
    node: tcwg-coordinator
    concurrent: false
    display-name: 'TCWG CCC Report Stale RR Jobs (in_production)'
    scm:
      - jenkins-scripts-master
    triggers:
      - timed: '@daily'
    wrappers:
      - timeout:
          timeout: 300
      - timestamps
      - ssh-agent-credentials:
          # tcwg-buildslave user id
          users:
            - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
    builders:
      - shell: |
          #!/bin/bash
          set -euf -o pipefail
          set -x

          rm -rf artifacts
          mkdir artifacts
          bash -x ./jenkins-scripts/tcwg-report-stale-rr-jobs.sh --days "$days" \
              --report_projects in_production \
              $days_per_project_extra_params \
              --output artifacts/stale-jobs.log
          bash -x ./jenkins-scripts/tcwg-report-stale-rr-jobs.sh \
              --classify artifacts/stale-jobs.log \
              --output artifacts/stale-jobs-analysis.log || true
          # Count the number non-empty nor non-comments lines
          n_lines=$(grep -c -v -E '^#|^$' artifacts/stale-jobs.log || true)
          ./jenkins-scripts/tcwg-report-ci-status.sh > artifacts/ci-status.log
          if [ x"$n_lines" != x"0" ]; then
            (
              echo "Jobs with no new results in $days days ($n_lines entries):"
              cat artifacts/ci-status.log
              cat artifacts/stale-jobs-analysis.log
              cat artifacts/stale-jobs.log
            ) > artifacts/email-body.txt
            exit 1
          fi
    publishers:
        - archive:
            artifacts: 'artifacts/**'
            latest-only: false
        - email-ext:
            recipients: 'maxim.kuvyrkov@linaro.org, laurent.alfonsi@linaro.org'
            content-type: text
            body: |
              ${FILE,path="artifacts/email-body.txt"}
            failure: true
            aborted: true
# checksum: 0a99ef8ceea59fe20d7b8572c69ca6b1
