Commit c14d11ae authored by Christos Stavrakakis's avatar Christos Stavrakakis

ci: Parse branch from repository

Guess the branch to build, based on the current branch of the
repository. Also track all remote branches when cloning Synnefo, because
it is needed by devflow.
parent 88860428
......@@ -5,8 +5,9 @@ build_timeout = 240
apt_repo = squeeze/
# Synnefo git repo
synnefo_repo =
# Git branch to test (specify sha1 or branch name)
synnefo_branch = HEAD
# Git branch to test (specify sha1 or branch name). If not set, the
# branch/sha will result from the current repository.
synnefo_branch =
# snf-deploy git repo
deploy_repo =
# Defines the schema that snf-deploy will use
......@@ -9,6 +9,7 @@ import sys
import time
import logging
import fabric.api as fabric
import subprocess
from ConfigParser import ConfigParser, DuplicateSectionError
from kamaki.cli import config as kamaki_config
......@@ -352,20 +353,36 @@ class SynnefoCI(object):
_run(cmd, False)
synnefo_repo = self.config.get('Global', 'synnefo_repo')
synnefo_branch = self.config.get('Global', 'synnefo_branch')
synnefo_branch = self.config.get("Global", "synnefo_branch")
if synnefo_branch == "":
synnefo_branch =\
subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"],
if synnefo_branch == "HEAD":
synnefo_branch = \
subprocess.Popen(["git", "rev-parse","--short", "HEAD"],
stdout=subprocess.PIPE).communicate()[0].strip()"Will use branch %s" % synnefo_branch)
# Currently clonning synnefo can fail unexpectedly
cloned = False
for i in range(3):
for i in range(10):
self.logger.debug("Clone synnefo from %s" % synnefo_repo)
cmd = ("git clone --branch %s %s"
% (synnefo_branch, synnefo_repo))
_run(cmd, False)
_run("git clone %s synnefo" % synnefo_repo, False)
cloned = True
self.logger.warning("Clonning synnefo failed.. retrying %s"
% i)
cmd ="""
cd synnefo
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
git branch --track ${branch##*/} $branch
git checkout %s
""" % (synnefo_branch)
_run(cmd, False)
if not cloned:
self.logger.error("Can not clone Synnefo repo.")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment