+ def _get_build_number(self, job, build_type):
+ """Get the number of the job defined by its name:
+ - lastSuccessfulBuild
+ - lastCompletedBuild
+
+ :param job: Job name.
+ :param build_type: Build type:
+ - lastSuccessfulBuild
+ - lastCompletedBuild
+ :type job" str
+ :raises PresentationError: If it is not possible to get the build
+ number.
+ :returns: The build number.
+ :rtype: int
+ """
+
+ # defined as a range <start, end>
+ if build_type == "lastSuccessfulBuild":
+ # defined as a range <start, lastSuccessfulBuild>
+ ret_code, build_nr, _ = get_last_successful_build_number(
+ self.environment["urls"]["URL[JENKINS,CSIT]"], job)
+ elif build_type == "lastCompletedBuild":
+ # defined as a range <start, lastCompletedBuild>
+ ret_code, build_nr, _ = get_last_completed_build_number(
+ self.environment["urls"]["URL[JENKINS,CSIT]"], job)
+ else:
+ raise PresentationError("Not supported build type: '{0}'".
+ format(build_type))
+ if ret_code != 0:
+ raise PresentationError("Not possible to get the number of the "
+ "build number.")
+ try:
+ build_nr = int(build_nr)
+ return build_nr
+ except ValueError as err:
+ raise PresentationError("Not possible to get the number of the "
+ "build number.\nReason: {0}".format(err))
+