# jenkins environment - parameters
ENV.setdefault('NO_UPLOAD','')
+ENV.setdefault('DISTRIBUTION','squeeze')
GIT_REPO_PATH = ENV['GIT_REPO_PATH']
# local constants
# Act II: make decissions
- if re.match(STABLE_BRANCHES_RE,ENV['GIT_BRANCH']):
+ if re.match(STABLE_BRANCHES_RE, ENV['GIT_BRANCH']):
new_dist = 'production-proposed-updates'
new_version = '{version}'.format(
version = curr_version,
# replace valid debian version chars that are invalid for git tagging
new_tag = curr_version.replace('~','_')
new_tag = new_tag.replace(':',',')
- # reset actions
- # .. always include successful build packages into CIDB
- do_cidb = True
- do_liveboot_request = True
# .. only take care of changelog automation if we want it to
if ENV['GIT_BRANCH'] in AUTO_CHANGELOG_REPONAMES:
do_autoincrement = 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
- remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag]
- if len(remote_tag) > 0:
- if remote_tag[0].commit.id == curr_commit:
- logger.info('Tag was already created for this commit.')
- do_tagging = False
+ # reset actions
+ if ENV['DISTRIBUTION'] == 'squeeze':
+ # .. always include successful build packages into CIDB
+ do_cidb = True
+ 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
+ remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag]
+ if len(remote_tag) > 0:
+ if remote_tag[0].commit.id == curr_commit:
+ logger.info('Tag was already created for this commit.')
+ do_tagging = False
+ else:
+ logger.error('Tag was already created for another commit.')
+ exit_error()
else:
- logger.error('Tag was already created for another commit.')
- exit_error()
+ do_tagging = True
+ # .. just used for GitBuildPackage()
+ pb_suite = new_dist
else:
- do_tagging = True
-
- elif re.match(DEVELOP_BRANCHES_RE,ENV['GIT_BRANCH']):
+ # TODO: tagging, cidb and liveboot makes no sense yet for other dists
+ # TODO: align reprepro to also use naming scheme for squeeze
+ pb_suite = 'master-' + ENV['DISTRIBUTION']
+ dput_obj.contents.update({
+ 'incoming': '/srv/profitbricks-repository/incoming/profitbricks-wheezy',
+ })
+
+ elif re.match(DEVELOP_BRANCHES_RE, ENV['GIT_BRANCH']):
new_dist = 'pre-staging'
new_version = '{version}~develop{date}+{build}+{commit}'.format(
version = curr_version,
)
# reset actions
# .. always include successful build packages into CIDB
- do_cidb = True
- # .. never tag in-development builds
- do_tagging = False
+ if ENV['DISTRIBUTION'] == 'squeeze':
+ do_cidb = True
+ pb_suite = new_dist
+ else:
+ pb_suite = 'develop-' + ENV['DISTRIBUTION']
- elif re.match(EXPERIMENTAL_BRANCHES_RE,ENV['GIT_BRANCH']):
+ elif re.match(EXPERIMENTAL_BRANCHES_RE, ENV['GIT_BRANCH']):
new_dist ='dev-'+ ENV['GIT_BRANCH'].replace("/","-")
new_version = '{version}~experimental{date}+{build}+{commit}'.format(
version = curr_version,
'incoming': '/srv/dev-repository/incoming/',
'post_upload_command': 'ssh reprepro@alexandria.pb.local /srv/dev-repository/bin/pb_processincoming',
})
+ pb_suite = new_dist
+ else:
+ pb_suite = 'experimental-' + ENV['DISTRIBUTION']
+
+ else:
+ logger.error('Don\'t know how to handle branch "{branch}".'.format(
+ branch = ENV['GIT_BRANCH'],
+ )
+ 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/'):
# if ENV['GIT_BRANCH_NAME'] == 'pre-staging':
# version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit[0:7])
# version = '%s~alpha%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit[0:7])
# changelog_distro = 'unstable'
- # .. just used for GitBuildPackage()
- pb_suite = new_dist
-
# ACT III: do something actually
# .. do some housekeeping first
''.join([block.__str__() for block in cl._blocks[0:2]])))
- # ACT IV: preparations are set, let's build
+ # ACT IV: preparations are done, let's build
+ logger.info('Building ...')
gbp = git_buildpackage.GitBuildPackage(
upstream_branch = ENV['GIT_BRANCH'],
debian_branch = ENV['GIT_BRANCH'],
- dist = 'squeeze',
+ dist = ENV['DISTRIBUTION'],
arch = 'amd64',
pb_suite = pb_suite,
git_commit_id = curr_commit[0:7]
)
- logger.info('Building ...')
ret = gbp.build()
+
# .. remove last commit (the one where we added the changelog entry)
gitrepo.git.reset('--soft', 'HEAD~1')
gitrepo.git.tag(version_tag)
except Exception as error:
logger.error('Could not create tag: ', exc_info=error)
+ figlet('Tagging failed')
exit_error()
try:
gitrepo.git.push('origin', version_tag)
except Exception as error:
logger.error('Could not push tag: ', exc_info=error)
+ figlet('Tagging failed')
exit_error()
logger.info('Tagged as "%s".' % version_tag)
figlet('Upload OK')
except Exception as error:
- figlet('Upload failed')
logger.error('Upload failed. See above for details.')
+ figlet('Upload failed')
exit_error()
BUILD_END,
)
figlet('CIDB OK')
+
except Exception as error:
- figlet('CIDB failed')
logger.error("package instance not added to DB: ", exc_info=error)
+ figlet('CIDB failed')
exit_error()
# .. finally trigger the next liveboot automatically if we succeed with CIDB
figlet('Liveboot OK')
except:
logger.debug("liveboot request failed")
+ figlet('Liveboot failed')
+ exit_error()
# finally, finished!
logger.info('---------------------------------------------------------------------------------------------------------')