1abb37c58SSriram Melkote#!/bin/bash
2abb37c58SSriram Melkote
3abb37c58SSriram Melkoteif [ ! -f ~/.cienv ]; then
4abb37c58SSriram Melkotecat > ~/.cienv <<EOF
580992523SSriram Melkote    export CINAME=ci-views
6abb37c58SSriram Melkote    export WORKSPACE=/opt/build
7abb37c58SSriram Melkote    export RELEASE=5.0.0
8abb37c58SSriram Melkote    export MANIFEST="couchbase-server/spock.xml"
9abb37c58SSriram Melkote    export MODE="test"
1080992523SSriram Melkote    export BRANCH="unstable"
11abb37c58SSriram Melkote    #export WATCHERS="somebody@couchbase.com nobody@couchbase.com"
1280992523SSriram Melkote    #export PEGGED=1979          # Set to fix base build, 0 means latest
1380992523SSriram Melkote    #export GERRIT="90331 90332" # Pick up uncommitted changes from gerrit
14abb37c58SSriram MelkoteEOF
15abb37c58SSriram Melkotefi
16abb37c58SSriram Melkotesource ~/.cienv
17abb37c58SSriram Melkote
18abb37c58SSriram Melkoteif [ "$WORKSPACE" = "" ]; then
19abb37c58SSriram Melkote  echo 'WORKSPACE not set'
20abb37c58SSriram Melkote  exit 2
21abb37c58SSriram Melkotefi
22abb37c58SSriram Melkote
23abb37c58SSriram Melkoteif [ "$MODE" = "" ]; then
24abb37c58SSriram Melkote  echo MODE must be set to 'test'
25abb37c58SSriram Melkote  exit 2
26abb37c58SSriram Melkotefi
27abb37c58SSriram Melkote
28abb37c58SSriram Melkoteif [ "$MANIFEST" == "" ]; then
29abb37c58SSriram Melkote  echo MANIFEST must be set
30abb37c58SSriram Melkotefi
31abb37c58SSriram Melkote
32abb37c58SSriram Melkoteif [ "$RELEASE" == "" ]; then
33abb37c58SSriram Melkote  echo RELEASE must be set
34abb37c58SSriram Melkotefi
35abb37c58SSriram Melkote
36abb37c58SSriram Melkotecd /var/www
37abb37c58SSriram Melkote(ls -t logs-*.tar* | head -n 30; ls -t logs-*.tar*) | sort | uniq -u | xargs -r rm
38abb37c58SSriram Melkote(ls -t make-*.log | head -n 3; ls -t make-*.log) | sort | uniq -u | xargs -r rm
39abb37c58SSriram Melkoteexport TS="`date +%d.%m.%Y-%H.%M`"
40abb37c58SSriram Melkoteecho '<html><head></head><body><pre>' > /var/www/views-current.html
41abb37c58SSriram Melkotechmod a+rx /var/www/views-current.html
42abb37c58SSriram Melkotedobuild clean 1>>/var/www/views-current.html 2>&1; rc=$?
43abb37c58SSriram Melkotetest $rc -eq 0 && dotest 1>>/var/www/views-current.html 2>&1; rc=$?
44abb37c58SSriram Melkoteecho '</pre>' >> /var/www/views-current.html
45abb37c58SSriram Melkoteif [ $rc -eq 0 ]; then status=pass; else status=fail; fi
46abb37c58SSriram Melkoteecho '<pre>' >> /var/www/views-current.html
47abb37c58SSriram Melkotegzip ${WORKSPACE}/logs.tar 2>&1 1>/dev/null
48abb37c58SSriram Melkoteecho "Version: <a href='versions-$TS.cfg'>versions-$TS.cfg</a>" >> /var/www/views-current.html
49abb37c58SSriram Melkoteecho "Build Log: <a href='make-$TS.log'>make-$TS.log</a>" >> /var/www/views-current.html
50abb37c58SSriram Melkoteecho "Server Log: <a href='logs-$TS.tar.gz'>logs-$TS.tar.gz</a>" >> /var/www/views-current.html
51abb37c58SSriram Melkoteecho "</pre><h1>Finished</h1></body></html>" >> /var/www/views-current.html
52abb37c58SSriram Melkotecp  /var/www/views-current.html /var/www/views-$TS.$status.html
53abb37c58SSriram Melkotemv ${WORKSPACE}/make.log /var/www/make-$TS.log
54abb37c58SSriram Melkotemv ${WORKSPACE}/logs.tar.gz /var/www/logs-$TS.tar.gz
55abb37c58SSriram Melkotemv ${WORKSPACE}/versions.cfg /var/www/versions-$TS.cfg
56abb37c58SSriram Melkotedowatch
57