Merge branch '15713-controller-error-log'
[arvados.git] / sdk / java-v2 / test-in-docker.sh
1 #!/bin/bash -x
2 #
3 # Copyright (C) The Arvados Authors. All rights reserved.
4 #
5 # SPDX-License-Identifier: AGPL-3.0 OR Apache-2.0
6 #
7 set -e
8
9 format_last_commit_here() {
10     local format="$1"; shift
11     TZ=UTC git log -n1 --first-parent "--format=format:$format" .
12 }
13
14 version_from_git() {
15     # Output the version being built, or if we're building a
16     # dev/prerelease, output a version number based on the git log for
17     # the current working directory.
18     if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
19         echo "$ARVADOS_BUILDING_VERSION"
20         return
21     fi
22
23     local git_ts git_hash prefix
24     if [[ -n "$1" ]] ; then
25         prefix="$1"
26     else
27         prefix="0.1"
28     fi
29
30     declare $(format_last_commit_here "git_ts=%ct git_hash=%h")
31     ARVADOS_BUILDING_VERSION="$(git describe --abbrev=0).$(date -ud "@$git_ts" +%Y%m%d%H%M%S)"
32     echo "$ARVADOS_BUILDING_VERSION"
33
34
35 nohash_version_from_git() {
36     version_from_git $1 | cut -d. -f1-3
37 }
38
39 timestamp_from_git() {
40     format_last_commit_here "%ct"
41 }
42 if [[ -n "$1" ]]; then
43     build_version="$1"
44 else
45     build_version="$(version_from_git)"
46 fi
47 #UID=$(id -u) # UID is read-only on many systems
48 exec docker run --rm --user $UID -v $PWD:$PWD -w $PWD gradle /bin/sh -c 'gradle clean && gradle test && gradle jar install '"$gradle_upload"