Exemple #1
0
    def get_build(self, build_number, depth=None):
        """get build by number.

        Also support special build:
                firstBuild
                lastBuild
                lastStableBuild
                lastSuccessfulBuild
                lastCompletedBuild
                lastFailedBuild
        """
        # if build_number is not int, maybe it is like "lastStableBuild"
        if not isinstance(build_number, int):
            build_number = self._get_build_number(build_number)

        url = self.builds.get(build_number)
        if not url:
            if build_number >= self.next_number:
                raise exception.NoBuildData(build_number)
            else:
                raise exception.DeletedBuild(build_number)

        return self.job.jenkins.PromotionBuild(url,
                                               build_number,
                                               promotion=self,
                                               depth=depth)
Exemple #2
0
    def _get_build_number(self, build_type):
        """get special build number by type.

        Args:
            build_type:
                firstBuild
                lastBuild
                lastStableBuild                                                                     
                lastSuccessfulBuild
                lastCompletedBuild
                lastFailedBuild
        """                                             
        data = self.poll(tree='%s[number]' % build_type)

        info = data.get(build_type)
        if not info:
            raise exception.NoBuildData(build_type)
        return info["number"]