Try and get a valid branch name on jenkins

This commit is contained in:
Christian committed 2012-12-03 08:23:21 -05:00
1 parent 39a146f8e6
commit 25f1ddac30
1 file changed
+10 -7
+10 -7
View File
@@ -47,13 +47,16 @@ def main():
(mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups() (mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups()
cmd = "git rev-parse --abbrev-ref HEAD" if os.getenv("GIT_BRANCH") is None:
try: cmd = "git rev-parse --abbrev-ref HEAD"
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) try:
branch, _ = process.communicate() process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
except OSError: branch, _ = process.communicate()
print("Git not found") except OSError:
branch="none" print("Git not found")
branch="none"
else:
branch=os.getenv("GIT_BRANCH")
with open("fmlversion.properties","w") as f: with open("fmlversion.properties","w") as f:
f.write("%s=%s\n" %("fmlbuild.major.number",major)) f.write("%s=%s\n" %("fmlbuild.major.number",major))