- scm:
    name: abe
    scm:
        - git:
            url: https://gitlab.com/Linaro/tcwg/abe.git
            refspec: +refs/heads/master:refs/remotes/origin/master
            branches:
                - master
            basedir: abe
            skip-tag: true
            wipe-workspace: false
            clean:
                before: true
            prune: true
- scm:
    name: jenkins-scripts
    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
- scm:
    name: dockerfiles
    scm:
        - git:
            url: https://git.linaro.org/ci/dockerfiles.git
            refspec: +refs/heads/master:refs/remotes/origin/master
            branches:
                - master
            basedir: dockerfiles
            skip-tag: true
            wipe-workspace: false
            clean:
                before: true
            prune: true
- job:
    name: tcwg-abe-tested
    project-type: multijob
    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
        - build-blocker:
            use-build-blocker: true
            blocking-jobs:
              - "ci-dockerfiles-deployment"
            queue-scanning: 'ALL'
        - throttle:
            max-total: 1
            option: project
    parameters:
        - bool:
            name: no_tests_just_update_tested
            default: 'false'
            description: 'Do not run tests, and just update abe:tested'
        - string:
            name: distro
            default: 'lts_1'
            description: 'Distro image to use'
    disabled: false
    node: tcwg-coordinator
    concurrent: true
    display-name: 'TCWG BBB Update tested branches (ABE, jenkins-scripts, dockerfiles) after extended validation'
    scm:
        - abe
        - jenkins-scripts
        - dockerfiles
    triggers:
        # Daily
        - pollscm:
            cron: 'H H * * *'
    wrappers:
        - timeout:
            timeout: 600
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
    builders:
        - shell: |
            #!/bin/bash
            # Print out environment for debug purposes.
            env | grep "^GIT"
        - conditional-step:
            condition-kind: strings-match
            condition-string1: '${ENV,var="no_tests_just_update_tested"}'
            condition-string2: 'false'
            steps:
              - multijob:
                  name: 'ABE extended tests'
                  condition: SUCCESSFUL
                  projects:
                    - name: tcwg-abe-extended
                      predefined-parameters: |
                        abe_branch=$GIT_COMMIT
                        scripts_branch=$GIT_COMMIT_1
                        distro=lts_1
        - shell: |
            #!/bin/bash

            set -ex
            ./jenkins-scripts/docker-run.sh --distro $distro -- ./jenkins-scripts/tcwg-update-tested.sh --GIT_COMMIT $GIT_COMMIT --GIT_COMMIT_1 $GIT_COMMIT_1 --GIT_COMMIT_2 $GIT_COMMIT_2 --verbose true
    publishers:
        - email-ext:
            recipients: 'tcwg-validation@linaro.org'
            aborted: true
