Try and get a valid branch name on jenkins

This commit is contained in:
Christian 2012-12-03 08:23:21 -05:00
parent 16418dd7ad
commit 461173a778
1 changed files with 10 additions and 7 deletions

View File

@ -47,13 +47,16 @@ def main():
(mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups()
cmd = "git rev-parse --abbrev-ref HEAD"
try:
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
branch, _ = process.communicate()
except OSError:
print("Git not found")
branch="none"
if os.getenv("GIT_BRANCH") is None:
cmd = "git rev-parse --abbrev-ref HEAD"
try:
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
branch, _ = process.communicate()
except OSError:
print("Git not found")
branch="none"
else:
branch=os.getenv("GIT_BRANCH")
with open("fmlversion.properties","w") as f:
f.write("%s=%s\n" %("fmlbuild.major.number",major))