# import local modules
from add_liveboot_request import add_liveboot_request
-from common_code import figlet, logger_init, exit_ok, exit_error, ENV, \
- BIN_SUDO, BUILD_AREA, BIN_RM, BIN_DCH, BIN_GIT_DCH
+from common_code import (figlet, logger_init, exit_ok, exit_error, ENV, BIN_SUDO, BUILD_AREA,
+ BIN_RM, BIN_DCH, BIN_GIT_DCH)
from db_add import add_package_instances
from lib import dput
from lib import gitpkg
# from common_code
-logger = logger_init(re.match('^(.*/jenkins_build_script/)(.*)',__file__).groups()[1])
+logger = logger_init(re.match('^(.*/jenkins_build_script/)(.*)', __file__).groups()[1])
# jenkins environment - parameters
ENV.setdefault('NO_UPLOAD', '')
# .. repository related
gitrepo = git.Repo('.')
- if not hasattr(gitrepo,'remotes'):
+ if not hasattr(gitrepo, 'remotes'):
# this should be part of 'git' lib, but it isn't right now
gitrepo.remotes = {}
for remote in gitrepo.git.remote('-v').split('\n'):
name, url, type = remote.split()
type = type.strip('()')
- if not gitrepo.remotes.has_key(name):
+ if name not in gitrepo.remotes:
gitrepo.remotes.update({name: {type: url}})
else:
gitrepo.remotes[name].update({type: url})
curr_version = cl.full_version
curr_dist = cl.distributions
-
# Act II: make decissions
# compatibility until call_jenkins was replaced
if curr_dist not in ('squeeze', 'wheezy'):
do_liveboot_request = True
# .. fail if we already found the tag we would create upon a successfull build,
# except, the existing tag uses the same commit as we were triggered with
- # FIXME: tagging only works for squeeze this way, change it to make it multipledist compatible
+ # FIXME: tagging only works for squeeze this way, change it to make it multipledist
+ # compatible
remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag]
if not do_autoincrement and len(remote_tag) > 0:
# FIXME: .id attribute but avl. in wheezy based git lib
#FIXME: get rid of jenkins parameter, instead use git remote
#if GIT_REPO_PATH.startswith('/srv/git/dev/'):
# if ENV['GIT_BRANCH_NAME'] == 'pre-staging':
- # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit_id[0:7])
+ # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER,
+ # curr_commit_id[0:7])
# changelog_distro = 'pre-staging'
# else:
# # use shorter date because we can
'login': 'reprepro',
'incoming': reprepro_base + '/incoming/profitbricks',
'allow_unsigned_uploads': 1,
- 'post_upload_command': 'ssh reprepro@alexandria.pb.local ' + reprepro_base + '/bin/pb_processincoming',
+ 'post_upload_command': 'ssh reprepro@alexandria.pb.local ' + reprepro_base +
+ '/bin/pb_processincoming',
}
)
logger.debug(gitrepo.git.checkout(dst_branch))
logger.debug(gitrepo.git.pull())
logger.debug(gitrepo.git.merge(src_branch))
- logger.info('Rebase and merge from branch "{src_branch}" completed. Now in "{dst_branch}".'.format(
- dst_branch=dst_branch,
- src_branch=src_branch,
- ))
+ logger.info('Rebase and merge from branch "{src_branch}" completed. Now in '
+ '"{dst_branch}".'.format(dst_branch=dst_branch, src_branch=src_branch))
except Exception as error:
logger.error('Rebase has failed!\n\n%s\n' % error.stderr, exc_info=error)
logger.debug(gitrepo.git.rebase('--abort'))
- logger.debug(gitrepo.git.reset('--hard',src_branch))
+ logger.debug(gitrepo.git.reset('--hard', src_branch))
if os.path.exists('.git/rebase-apply'):
- subprocess.check_call(['rm','-rf','.git/rebase-apply'])
+ subprocess.check_call(['rm', '-rf', '.git/rebase-apply'])
exit_error()
if 'no-test' in build_triggers:
# .. 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...')
+ raise Exception('debian/control sets "section" to unknown. '
+ 'This is not allowed, failing...')
exit_error()
# .. and update changelog if we trust the package
new_version = cl.full_version
new_tag = new_version.replace('~', '_').replace(':', ',')
except Exception as error:
- logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' % error.stderr, exc_info=error)
+ logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' %
+ error.stderr, exc_info=error)
exit_error()
# .. or set approriate versions for our development candidates
### Beware when using 'merge' trigger: The above command specifies the target
### branch already while you want to run on original branch '{orig_branch}'.
###
-'''.format(
- hostname=socket.gethostname(),
- jenkins_user=ENV['USER'],
- jenkins_workspace=ENV['WORKSPACE'],
- builder_env=' '.join(['{k}="{v}"'.format(k=key, v=builder.env[key],)
- for key in builder.env.keys()
- ]),
- command=' '.join(builder.command),
- orig_branch=ENV['GIT_BRANCH'],
- ))
+'''.format(hostname=socket.gethostname(),
+ jenkins_user=ENV['USER'],
+ jenkins_workspace=ENV['WORKSPACE'],
+ builder_env=' '.join(['{k}="{v}"'.format(k=key, v=builder.env[key],)
+ for key in builder.env.keys()]),
+ command=' '.join(builder.command),
+ orig_branch=ENV['GIT_BRANCH'],
+ ))
# .. and finally handle the result
if ret:
exit_error()
# finally, finished!
- logger.info('---------------------------------------------------------------------------------------------------------')
+ logger.info('-' * 99)
figlet('Success!!!')
exit_ok()