# jenkins environment - parameters
ENV.setdefault('NO_UPLOAD', '')
+ENV.setdefault('BUILD_TRIGGERS', '')
#ENV.setdefault('DISTRIBUTION', 'squeeze')
#GIT_REPO_PATH = ENV['GIT_REPO_PATH']
+ENV['BUILD_TRIGGERS'] = ENV['BUILD_TRIGGERS'].split()
# local constants
BUILD_START = datetime.datetime.now()
gitrepo = git.Repo('.')
local_branch = re.match('^(origin/)?(.*)', ENV['GIT_BRANCH']).groups()[1]
remote_branch = os.path.join('origin', local_branch)
- curr_commit = gitrepo.commit(ENV['GIT_COMMIT'])
- # collect all 'trigger' expressions found in the commit message, i.e.
- # <<< "[merge][no-test][provisioning] my commit message"
- # >>> ['merge','no-test','provisioning']
- commit_triggers = re.findall('\[([^\]]+)\]', curr_commit.message)
+ curr_commit = gitrepo.commit(remote_branch)
# id attribute used in python-git 0.3.2~RC1-1 found in wheezy
if hasattr(curr_commit, 'hexsha'):
curr_commit_id = curr_commit.hexsha
if re.match(COMMIT_TRIGGER_BRANCHES_RE, ENV['GIT_BRANCH']):
do_triggers = True
+ else:
+ logger.info('Not evaluating triggers for branch ' + ENV['GIT_BRANCH'])
if re.match(STABLE_BRANCHES_RE, ENV['GIT_BRANCH']):
if re.match('^(ps_|dev_).*$', ENV['JOB_NAME']):
gitrepo.git.fetch('--force', '--prune').strip()
gitrepo.git.reset('--hard', 'HEAD').strip()
gitrepo.git.execute(['sudo', 'git', 'clean', '-fdx']).strip()
- gitrepo.git.branch(
- '-D',
- '{branch}'.format(branch=local_branch),
- with_exceptions=False,
- ).strip()
+ gitrepo.git.branch('-D', local_branch, with_exceptions=False).strip()
# .. and re-checkout the requested branch
logger.info('Checkout branch {branch}.'.format(branch=remote_branch))
- gitrepo.git.checkout(
- '-b',
- '{lbranch}'.format(lbranch=local_branch),
- '{rbranch}'.format(rbranch=remote_branch),
- ).strip()
+ gitrepo.git.checkout('-b', local_branch, remote_branch).strip()
logger.debug('Status is now:\n{status}'.format(
status=gitrepo.git.status().strip(),
))
# .. do some CI magic now, if requested
if do_triggers:
- if 'merge' in commit_triggers and local_branch != 'integration':
- if 'no-test' in commit_triggers:
+ if 'merge' in ENV['BUILD_TRIGGERS'] and local_branch != 'integration':
+ if 'no-test' in ENV['BUILD_TRIGGERS']:
logger.info('Force building with tests as we also merge your branch.')
- commit_triggers.remove('no-test')
+ ENV['BUILD_TRIGGERS'].remove('no-test')
src_branch = local_branch # save the original branch
dst_branch = 'integration' # define the new branch
gitrepo.git.checkout(dst_branch)
gitrepo.git.pull()
gitrepo.git.merge(src_branch)
- logger.info('Checked out "{dst_branch}" branch after rebase and merge completed from branch "{src_branch}".'.format(
+ logger.info('Rebase and merge from branch "{src_branch} completed. Now in "{dst_branch}".'.format(
dst_branch=dst_branch,
src_branch=src_branch,
))
- if 'no-test' in commit_triggers:
+ if 'no-test' in ENV['BUILD_TRIGGERS']:
# debian/rules from vdc-bundles determines maven options for tests
# depending whether DEB_NOTEST environment variable is defined
# FIXME: ensure this environment variable is available in chroot