- builder:
    name: gerrit-buck-checkout
    builders:
      - shell: |
          #!/bin/bash -xe
          CLONEMAP=`mktemp`
          function cleanup {
              rm -f $CLONEMAP
          }
          trap cleanup EXIT
          cat > $CLONEMAP << EOF
          clonemap:
            - name: openstack-infra/gerrit
              dest: gerrit
          EOF
          /usr/zuul-env/bin/zuul-cloner -m $CLONEMAP \
              --cache-dir /opt/git \
              git://git.openstack.org openstack-infra/gerrit

- job:
    name: gate-gerrit-buck
    node: ubuntu-trusty

    wrappers:
      - build-timeout:
          timeout: 40
      - timestamps

    builders:
      - install-distro-packages
      - revoke-sudo
      - install-buck
      - gerrit-buck-checkout
      - shell: |
          #!/bin/bash -xe
          export PATH=`pwd`/buck/bin:$PATH
          cd gerrit
          /usr/local/jenkins/slave_scripts/version-properties.sh
          source version.properties
          buck clean
          buck test --all --exclude slow
          buck build release
          cp buck-out/gen/release/release.war buck-out/gen/gerrit-$PROJECT_VER.war

    publishers:
      - war:
          warfile: 'gerrit/buck-out/gen/gerrit-*.war'
          target: 'tarballs/ci/test'
      - console-log


- job:
    name: gerrit-package-buck
    node: ubuntu-trusty

    wrappers:
      - build-timeout:
          timeout: 40
      - timestamps

    builders:
      - install-distro-packages
      - revoke-sudo
      - install-buck
      - gerrit-buck-checkout
      - shell: |
          #!/bin/bash -xe
          export PATH=`pwd`/buck/bin:$PATH
          cd gerrit
          /usr/local/jenkins/slave_scripts/version-properties.sh
          source version.properties
          buck clean
          buck build release
          cp buck-out/gen/release/release.war buck-out/gen/gerrit-$PROJECT_VER.war

    publishers:
      - war:
          warfile: 'gerrit/buck-out/gen/gerrit-*.war'
          target: 'tarballs/ci/gerrit'
      - console-log