- job:
    name: infrastructure-linaro-license-protection
    project-type: freestyle
    defaults: global
    logrotate:
        daysToKeep: 30
        numToKeep: 30
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            everyone-flat:
                - job-build
                - job-cancel
    disabled: false
    node: docker-xenial-amd64
    display-name: 'Infrastructure - Unit Test CI for the linaro-license-protection repository'
    concurrent: true
    triggers:
        - gerrit:
            server-name: 'review.linaro.org'
            override-votes: true
            gerrit-build-successful-verified-value: 1
            gerrit-build-failed-verified-value: -1
            trigger-for-unreviewed-patches: true
            readable-message: false
            projects:
                - project-compare-type: 'PLAIN'
                  project-pattern: 'infrastructure/linaro-license-protection'
                  branches:
                    - branch-compare-type: 'PLAIN'
                      branch-pattern: 'master'
    wrappers:
        - timeout:
            timeout: 300
        - timestamps
    builders:
        - shell: |
            #!/bin/bash

            rm -rf ${WORKSPACE}/*
            echo "#${BUILD_NUMBER}-${GERRIT_PATCHSET_REVISION:0:8}" > ${WORKSPACE}/version.txt
            sudo apt-get update
            sudo apt-get install -y python-virtualenv git

            git clone -b ${GERRIT_BRANCH} --depth 1 https://git.linaro.org/${GERRIT_PROJECT}
            cd *
            git log -n1
            git fetch https://review.linaro.org/${GERRIT_PROJECT} ${GERRIT_REFSPEC}
            git checkout -q FETCH_HEAD

            ./unit-test.sh
        - build-name-setter:
            name: 'version.txt'
            file: true
