BUILD_ID = os.environ.get('BUILD_ID')
BUILD_URL = os.environ.get('BUILD_URL')
-#GIT_REPO_PATH = os.environ.get('GIT_REPO_PATH')
-#GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH)
-#GIT_OLD_ID = os.environ.get('GIT_OLD_ID')
-#GIT_NEW_ID = os.environ.get('GIT_NEW_ID')
-#GIT_UPSTREAM_BRANCH = os.environ.get('GIT_UPSTREAM_BRANCH')
-#GIT_DEBIAN_BRANCH = os.environ.get('GIT_DEBIAN_BRANCH')
-#GIT_DEBIAN_REMOTE_BRANCH = os.path.join('origin', '%s' %(GIT_DEBIAN_BRANCH))
+GIT_REPO_PATH = os.environ.get('GIT_REPO_PATH')
+GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH)
+GIT_BRANCH_NAME = os.environ.get('GIT_BRANCH_NAME')
GIT_TARGET_WORKSPACE = os.path.join(
CWD,
('%s-build%s' %(BUILD_ID, BUILD_NUMBER))
)
logging.getLogger('lib.git_helper').setLevel(logging.DEBUG)
options, args = getopts()
- #if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
- # logger.info('git clone was successfull')
- #else:
- # logger_loud_error('git clone was not successfull')
- # exit_error()
+ if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
+ logger.info('git clone was successfull')
+ else:
+ logger_loud_error('git clone was not successfull')
+ exit_error()
- #atexit.register(remove_git_target_workspace)
+ atexit.register(remove_git_target_workspace)
os.chdir(GIT_TARGET_DIR)
- #if not GIT_DEBIAN_BRANCH:
- # if GIT_UPSTREAM_BRANCH:
- # GIT_DEBIAN_BRANCH = GIT_UPSTREAM_BRANCH
- # logging.debug(
- # 'setting GIT_DEBIAN_BRANCH to %s',
- # GIT_UPSTREAM_BRANCH
- # )
- # else:
- # logger_loud_error('Could not determine GIT_DEBIAN_BRANCH')
- # exit_error()
- #elif not GIT_UPSTREAM_BRANCH:
- # if GIT_DEBIAN_BRANCH:
- # GIT_UPSTREAM_BRANCH = GIT_DEBIAN_BRANCH
- # logging.debug(
- # 'setting GIT_UPSTREAM_BRANCH to %s',
- # GIT_UPSTREAM_BRANCH
- # )
- # else:
- # logger_loud_error('Could not determine GIT_UPSTREAM_BRANCH')
- # exit_error()
- ##
- #repo = git.repo.Repo()
- #
- #if GIT_DEBIAN_BRANCH != 'master':
- # git_helper.git_new_branch_from(
- # GIT_DEBIAN_BRANCH,
- # os.path.join('origin', GIT_DEBIAN_BRANCH)
- # )
+ # FIXME: this is just needed for gbp and can go away eventually
+ if GIT_BRANCH_NAME:
+ GIT_UPSTREAM_BRANCH = GIT_BRANCH_NAME
+ GIT_DEBIAN_BRANCH = GIT_BRANCH_NAME
+ logging.debug(
+ 'setting GIT_UPSTREAM_BRANCH and GIT_DEBIAN_BRANCH to %s',
+ GIT_UPSTREAM_BRANCH
+ )
+ else:
+ logger_loud_error('Could not determine GIT_UPSTREAM_BRANCH')
+ exit_error()
+
+ repo = git.repo.Repo()
+
+ if GIT_BRANCH_NAME != 'master':
+ git_helper.git_new_branch_from(
+ GIT_BRANCH_NAME,
+ os.path.join('origin', GIT_BRANCH_NAME)
+ )
# git-buildpackage uses only treeish object in v0.5.10, so let's fetch the
# treeish refspec when a name was given (i.e. tag names, branch names,
# etc.)
# TODO: upgrade git-buildpackage
- #GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish(
- # os.path.join('origin', GIT_UPSTREAM_BRANCH)
- #)
+ GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish(
+ os.path.join('origin', GIT_UPSTREAM_BRANCH)
+ )
# now checkout the requested branch
- #if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
- # logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
- #else:
- # logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
- # exit_error()
+ if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
+ logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
+ else:
+ logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
+ exit_error()
# we need to make sure our jenkins config is used, so let's delete any
# other config available in repository that might be prefered
- #cleanup_files = ('.gbp.conf', 'debian/gbp.conf', '.git/gbp.conf')
- #result = git_helper.git_cleanup_branch(cleanup_files)
- #commit_files = result["goods"].keys()
- #if len(commit_files) > 0:
- # git_helper.git_commit(
- # "Cleanup branch for correct builds.",
- # commit_files
- # )
+ cleanup_files = ('.gbp.conf', 'debian/gbp.conf', '.git/gbp.conf')
+ result = git_helper.git_cleanup_branch(cleanup_files)
+ commit_files = result["goods"].keys()
+ if len(commit_files) > 0:
+ git_helper.git_commit(
+ "Cleanup branch for correct builds.",
+ commit_files
+ )
cmd = ['dpkg-parsechangelog']
parse_changelog = subprocess.Popen(
else:
version = '%s~develop%s' %(version, daily_date)
- # FIXME: check this is still correct
new_log = 'Generated by jenkins build of %s' % git_helper.git_get_commit_id()
cmd = [
# we need to commit here else git-buildpackage will use the existing debian/changelog...
# TODO: Later we should investigate why the "--ignore-new" trick
# did not work!
- #cmd = ['/usr/bin/git', 'add', '-A']
- #subprocess.check_call(cmd)
- #cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add new changelog entry']
- #subprocess.check_call(cmd)
-
- if not GIT_COMMITTER_EMAIL:
- #for commit in repo.commits():
- # if commit.id == GIT_NEW_ID:
- # GIT_COMMITTER_EMAIL = commit.committer.email
- # logger.debug(
- # 'Found "%s" in commit-id "%s" at "%s"'
- # %(GIT_COMMITTER_EMAIL, commit.id, repo.active_branch)
- # )
- #else:
- raise Exception('No git_committer_email found')
+ cmd = ['/usr/bin/git', 'add', '-A']
+ subprocess.check_call(cmd)
+ cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add new changelog entry']
+ subprocess.check_call(cmd)
if options.distribution in ('unstable' , 'experimental', 'pre-staging'):
pb_suite='pre-staging'
elif options.distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates'):
pb_suite='production-proposed-updates'
- #gbp = git_buildpackage.GitBuildPackage(
- # upstream_branch=GIT_UPSTREAM_BRANCH,
- # debian_branch=GIT_DEBIAN_BRANCH,
- # dist='squeeze',
- # arch='amd64',
- # pb_suite=pb_suite
- #)
+ gbp = git_buildpackage.GitBuildPackage(
+ upstream_branch=GIT_UPSTREAM_BRANCH,
+ debian_branch=GIT_DEBIAN_BRANCH,
+ dist='squeeze',
+ arch='amd64',
+ pb_suite=pb_suite
+ )
logger.info('used to start git-buildpackage here...')
- #ret = gbp.build()
- ret = 0
+ ret = gbp.build()
if ret:
logger_loud_error(
'git-buildpackage returned non-zero. exitcode was: %s' % ret