'^(origin/)?(develop|pre-staging|release/.*)$')
EXPERIMENTAL_BRANCHES_RE = re.compile(
'^(origin/)?(experimental|integration|(feature|poc|bugfix)/.*)$')
+COMMIT_TRIGGER_BRANCHES_RE = re.compile(
+ '^(origin/)?(feature/.*)$')
def getopts():
usage = '%prog [options]'
do_liveboot_request = False
do_reports = True
do_tagging = False
+ do_triggers = False
do_uploads = True
cl = changelog.Changelog()
reports_file = os.path.join(ENV['WORKSPACE'], '../build-area/result/reports.tgz',)
gitrepo = git.Repo('.')
curr_commit = gitrepo.commit(ENV['GIT_COMMIT'])
- # used in python-git 0.3.2~RC1-1 found in wheezy
+ # collect all 'trigger' expressions found in the commit message
+ commit_triggers = re.findall('\[([^\]]+)\]', curr_commit.message)
+ # 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
- # used in python-git 0.1.6-1 found in squeeze
+ # id attribute used in python-git 0.1.6-1 found in squeeze
elif hasattr(curr_commit, 'id'):
curr_commit_id = curr_commit.id
+
# .. dput related (some overrides happening below, though)
dput_obj = dput.Dput(
# Act II: make decissions
+ if re.match(COMMIT_TRIGGER_BRANCHES_RE, ENV['GIT_BRANCH']):
+ do_triggers = True
+
if re.match(STABLE_BRANCHES_RE, ENV['GIT_BRANCH']):
new_dist = 'stable'
new_version = '{version}'.format(
))
exit_error()
+
#FIXME: enable this once Florian acks.
#FIXME: get rid of jenkins parameter, instead use git remote
#if GIT_REPO_PATH.startswith('/srv/git/dev/'):
logger.debug('Distribution: "%s" => "%s"' %(curr_dist,new_dist))
logger.debug('Version: "%s" => "%s"' %(curr_version,new_version))
logger.debug('PB_SUITE: ' + pb_suite)
+ if do_triggers:
+ logger.debug('Triggers found: ' + commit_triggers)
if do_tagging:
logger.debug('Tag to create: ' + new_tag)
logger.debug('Upload configuration:\n%s' %(pformat(dput_obj.contents)))
if len(files) > 0:
logger.info('Delete previous upstream tarball(s)')
- cmd = [BIN_SUDO, BIN_RM, '-v']
- cmd.extend(files)
- ret = subprocess.Popen(
- cmd,
- shell=False,
- cwd='/',
- close_fds=True,
- stdout=sys.stdout,
- stderr=subprocess.STDOUT,
- env={'':''}
- ).wait()
- logger.debug('"{cmd}" returns {exitcode}.'.format(
- cmd = cmd,
- exitcode = ret
- ))
+ cmd = [BIN_SUDO, BIN_RM, '-v'] + files
+ if subprocess.check_call(cmd):
+ logger.info(cmd + ' succeeded.')
+ else:
+ logger.warn(cmd + ' failed.')
+
figlet('Cleanup OK')
+
+ # .. do some CI magic now, if requested
+ if do_triggers:
+
+ if 'merge' in commit_triggers:
+ if 'no-test' in commit_triggers:
+ logger.info('Force building with tests as we also merge your branch.')
+ commit_triggers.remove('no-test')
+
+ src_branch = ENV['GIT_BRANCH'] # save the original branch
+ dst_branch = 'integration' # define the new branch
+ ENV['GIT_BRANCH'] = dst_branch # reset env for git-buildpackage
+ # FIXME: error handling when rebase doesn't cleanly complete?
+ gitrepo.git.rebase('--onto', dst_branch, src_branch)
+ gitrepo.git.checkout(dst_branch)
+ logger.info('Checked out "%s" branch after rebase completed from branch "%s".' %(
+ dst_branch, src_branch))
+
+ if 'no-test' in commit_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
+ # (i.e. sudo)
+ ENV.update({'DEB_NOTEST':'TRUE'})
+
+
# .. NOW we can verify debian/control contents
for line in fileinput.input('debian/control'):
if line.lower().startswith('section: unknown'):
raise Exception('debian/control sets "section" to unknown. This is not allowed, failing...')
exit_error()
- # .. update changelog if we trust the package
+
+ # .. and update changelog if we trust the package
if do_autoincrement:
subprocess.check_call([BIN_DCH, '-i', 'Released by jenkins.'])
subprocess.check_call([BIN_GIT_DCH, '-R', '-a', '--spawn-editor=none'])
gitrepo.git.push('origin', 'master')
logger.info('Changelog incremented by jenkins using debian_build.py!')
- # .. or to set approriate versions for development candidates
+ # .. or set approriate versions for our development candidates
else:
cmd = [
BIN_DCH,
logger.info('Changelog updated by Jenkins using debian_build.py!')
- # let me see the first two changelog entries:
+ # let me see the first two entries or our adjusted changelog:
# TODO: use changelog python libs instead of DCH calls, see above
cl = changelog.Changelog()
cl.parse_changelog(open('debian/changelog'))
ret = gbp.build()
# .. remove last commit (the one where we added the changelog entry)
+ # FIXME: when 'merge': reset only on original branch?
+ # change checkout back to original branch?
gitrepo.git.reset('--soft', 'HEAD~1')
# .. now handle the result