~fginther/jenkins-launchpad-plugin/config-file-trigger

« back to all changes in this revision

Viewing changes to dputrunner.py

  • Committer: Tarmac
  • Author(s): Martin Mrazik
  • Date: 2012-09-18 06:38:00 UTC
  • mfrom: (44.2.5 multiple-ppas)
  • Revision ID: tarmac-20120918063800-kgu88ddxeo0oukcf
Adding support for dput-ing into multiple (comma separated) ppas.. Approved by Sergio Schvezov, jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
                     'pkg{PACKAGING_REVISION}~{DISTRIBUTION}1')
12
12
    distributions = []
13
13
    jenkinsBuildNumber = ''
 
14
    ppas = []
14
15
 
15
 
    def __init__(self, ppa, trunk, packagingBranch,
 
16
    def __init__(self, ppas, trunk, packagingBranch,
16
17
                 DEBFULLNAME, DEBEMAIL, revision=None,
17
18
                 versionFormat=None,
18
19
                 distributions=None, jenkinsBuildNumber=''):
22
23
            self.versionFormat = versionFormat
23
24
        self.distributions = distributions
24
25
        self.jenkinsBuildNumber = jenkinsBuildNumber
25
 
        self.ppa = ppa
 
26
        self.ppas = ppas
26
27
        self.trunk = trunk
27
28
        self.packagingBranch = packagingBranch
28
29
        self.revision = revision
35
36
                         error.message)
36
37
            return None
37
38
 
38
 
    def doDput(self, recipe, version_string, changelog_entry, distribution):
 
39
    def doDput(self, recipe, version_string, changelog_entry, distribution,
 
40
               ppa):
39
41
        logger.info('Going to dput version: ' + version_string)
40
42
        #export DEBFULLNAME=
41
43
        os.putenv('DEBFULLNAME', self.DEBFULLNAME)
55
57
        logger.debug('Calling: %r', debuild_call)
56
58
        subprocess.check_call(debuild_call, cwd=recipe.getTrunkDir())
57
59
        #dput $ppa *${version_string}_source.changes
58
 
        dput_call = ['dput', self.ppa, name + '_source.changes']
 
60
        dput_call = ['dput', ppa, name + '_source.changes']
59
61
        logger.debug('Calling: %r', dput_call)
60
62
        subprocess.check_call(dput_call, cwd=recipe.getBuildDir())
 
63
        #rm -f _source.ppa.upload
 
64
        rm_call = ['rm', '-f', name + '_source.ppa.upload']
 
65
        logger.debug('Calling: %r', rm_call)
 
66
        subprocess.check_call(rm_call, cwd=recipe.getBuildDir())
61
67
        #revert the previous dch calls to get a clean changelog
62
68
        logger.debug('Reverting the change made by dch call')
63
69
        recipe.revert()
70
76
        recipe = BzrRecipe(self.trunk, self.packagingBranch, self.revision)
71
77
 
72
78
        for distribution in self.distributions:
73
 
            formatedVersionString = self.formatVersionString(
 
79
            for ppa in self.ppas:
 
80
                formatedVersionString = self.formatVersionString(
74
81
                         PACKAGE_VERSION=recipe.getPackageVersion(),
75
82
                         BZR_REVISION=recipe.getTrunkRevno(),
76
83
                         PACKAGING_REVISION=recipe.getPackagingBranchRevno(),
77
84
                         JENKINS_BUILD_NUMBER=self.jenkinsBuildNumber,
78
85
                         DISTRIBUTION=distribution)
79
 
            if not formatedVersionString:
80
 
                logger.error('Aborting dput as no format string was specified')
81
 
                return False
82
 
            try:
83
 
                self.doDput(recipe, formatedVersionString,
84
 
                            "Automatic build of revision " +
85
 
                            str(recipe.getTrunkRevno()),
86
 
                            distribution)
87
 
            except subprocess.CalledProcessError as e:
88
 
                logger.error('Command %s returned non-zero exit status %d',
89
 
                    e.cmd, e.returncode)
90
 
                return False
 
86
                if not formatedVersionString:
 
87
                    logger.error(
 
88
                            'Aborting dput as no format string was specified')
 
89
                    return False
 
90
                try:
 
91
                    self.doDput(recipe, formatedVersionString,
 
92
                                "Automatic build of revision " +
 
93
                                str(recipe.getTrunkRevno()),
 
94
                                distribution,
 
95
                                ppa)
 
96
                except subprocess.CalledProcessError as e:
 
97
                    logger.error('Command %s returned non-zero exit status %d',
 
98
                                 e.cmd, e.returncode)
 
99
                    return False
91
100
        recipe.cleanup()
92
101
        return True