blob: 8574d1737657d6f26017af6317e1efab87d714ba [file] [log] [blame]
David Ostrovskyb513ac42019-11-03 09:36:24 +01001#!/usr/bin/env python
2
3# This script will be run by bazel when the build process starts to
4# generate key-value information that represents the status of the
5# workspace. The output should be like
6#
7# KEY1 VALUE1
8# KEY2 VALUE2
9#
10# If the script exits with non-zero code, it's considered as a failure
11# and the output will be discarded.
12
13from __future__ import print_function
14import subprocess
15import sys
16
17CMD = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty']
18
19
20def revision():
21 try:
22 return subprocess.check_output(CMD).strip().decode("utf-8")
23 except OSError as err:
24 print('could not invoke git: %s' % err, file=sys.stderr)
25 sys.exit(1)
26 except subprocess.CalledProcessError as err:
27 print('error using git: %s' % err, file=sys.stderr)
28 sys.exit(1)
29
30
31print("STABLE_BUILD_SERVICEUSER_LABEL %s" % revision())