]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
handle pre-staging branch for /dev projects. handle develop branch for /dev projects...
authorHolger Levsen <holger@layer-acht.org>
Thu, 12 Apr 2012 14:43:49 +0000 (16:43 +0200)
committerHolger Levsen <holger@layer-acht.org>
Thu, 12 Apr 2012 14:43:49 +0000 (16:43 +0200)
debian_build.py

index bcca4e211450961acbb5e8c78aef1905b68bd046..bd8b801f8580cf4971bbea95e5b17abf63f4f944 100755 (executable)
@@ -205,7 +205,7 @@ def getopts():
     parser.add_option(
             '--distribution',
             dest='distribution',
-            choices = ['stable', 'production', 'production-proposed-updates', 'testing', 'staging', 'unstable', 'pre-staging', 'experimental'],
+            choices = ['stable', 'production', 'production-proposed-updates', 'unstable', 'pre-staging', 'experimental'],
             default='unstable',
             help='The pkg distribution. Default: %default'
     )
@@ -326,10 +326,12 @@ if __name__ == '__main__':
         exit_error()
 
     # enforce correct distribution in debian/changelog for master and hotfix branches
-    if (GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/')) and not distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates'):
-        logger_error('Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution))
+    allowed_production_distros=('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates')
+    if (GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/')) and not distribution in allowed_production_distros:
+        logger_error('Distribution %s in debian/changelog not listed in %s' % allowed_production_distros )
         raise Exception(
-                'Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution)
+                'Distribution %s in debian/changelog not listed in %s' % allowed_production_distros 
+
         )
         exit_error()
 
@@ -338,26 +340,30 @@ if __name__ == '__main__':
     # get the current commit id
     current_commit = git_helper.git_get_commit_id()
 
-    if GIT_BRANCH_NAME == 'develop' or GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/') or GIT_BRANCH_NAME.startswith('release/'):
+    if GIT_BRANCH_NAME == 'develop' or GIT_BRANCH_NAME == 'pre-staging' or GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/') or GIT_BRANCH_NAME.startswith('release/'):
         daily_date = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
         if GIT_BRANCH_NAME.startswith('release/'):
+            changelog_distro = 'production-proposed-updates'
             # use shorter date as we can
             daily_date = datetime.datetime.now().strftime('%Y%m%d')
             version = '%s~rc%s+%s+%s' %(version, daily_date, BUILD_NUMBER, current_commit[0:7])
         elif GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/'):
+            changelog_distro ='dev-'+ GIT_BRANCH_NAME.replace("/","-")
             version = '%s~experimental%s+%s+%s' %(version, daily_date, BUILD_NUMBER, current_commit[0:7])
             # these uploads should go to a different repo:
             DPUT_OPTIONS = DPUT_OPTIONS_DEV
         else:
             version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, current_commit[0:7])
+            if GIT_REPO_PATH.startswith('/srv/git/dev/'):
+                if GIT_BRANCH_NAME == 'pre-staging':
+                    changelog_distro = 'pre-staging'
+                else:
+                    changelog_distro = 'unstable'
+            else:
+                    changelog_distro = 'pre-staging'
 
         new_log = 'Generated by jenkins build of %s' % current_commit
 
-        if GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/'):
-            changelog_distro ='dev-'+ GIT_BRANCH_NAME.replace("/","-")
-        else:
-            changelog_distro = options.distribution
-
         cmd = [
                 '/usr/bin/dch',
                 '--newversion',
@@ -405,13 +411,15 @@ if __name__ == '__main__':
     cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add new changelog entry']
     subprocess.check_call(cmd)
 
-    if GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/'):
-      pb_suite=changelog_distro
-    elif GIT_BRANCH_NAME.startswith('hotfix/') or GIT_BRANCH_NAME.startswith('release/') or options.distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates'):
-      pb_suite='production-proposed-updates'
-    elif options.distribution in ('unstable' , 'pre-staging'):
-      pb_suite='pre-staging'
-       
+    # if we wrote a changelog entry, use that one
+    if GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/') or GIT_BRANCH_NAME == 'develop' or GIT_BRANCH_NAME == 'pre-staging' or GIT_BRANCH_NAME.startswith('release/'):
+        pb_suite=changelog_distro
+    elif GIT_BRANCH_NAME.startswith('hotfix/') or GIT_BRANCH_NAME == 'master':
+        # just take suite from changelog for these branches
+        pb_suite=distribution
+    else:
+         raise Exception('unhandled branch, failing.')
+
     logger.info('dist: %s' %(pb_suite))
     cmd = ['figlet-figlet', '-t', 'dist: %s' %(pb_suite)]
     subprocess.check_call(cmd)