X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Futils.py;h=154b6e9b2306e3336fca6976e06ed28bc6bcc13b;hp=966d7f558b17ce554ef5bdc999641db01bc4cde8;hb=aaa58d348c375f80e65dfdf62a679dd0cbac4411;hpb=806d2bf874f34d80e92c700652f226359402b1e8 diff --git a/resources/tools/presentation/utils.py b/resources/tools/presentation/utils.py index 966d7f558b..154b6e9b23 100644 --- a/resources/tools/presentation/utils.py +++ b/resources/tools/presentation/utils.py @@ -172,15 +172,35 @@ def execute_command(cmd): return proc.returncode, stdout, stderr -def get_last_build_number(jenkins_url, job_name): +def get_last_successful_build_number(jenkins_url, job_name): + """Get the number of the last successful build of the given job. + + :param jenkins_url: Jenkins URL. + :param job_name: Job name. + :type jenkins_url: str + :type job_name: str + :returns: The build number as a string. + :rtype: str """ - :param jenkins_url: - :param job_name: - :return: + url = "{}/{}/lastSuccessfulBuild/buildNumber".format(jenkins_url, job_name) + cmd = "wget -qO- {url}".format(url=url) + + return execute_command(cmd) + + +def get_last_completed_build_number(jenkins_url, job_name): + """Get the number of the last completed build of the given job. + + :param jenkins_url: Jenkins URL. + :param job_name: Job name. + :type jenkins_url: str + :type job_name: str + :returns: The build number as a string. + :rtype: str """ - url = "{}/{}/lastSuccessfulBuild/buildNumber".format(jenkins_url, job_name) + url = "{}/{}/lastCompletedBuild/buildNumber".format(jenkins_url, job_name) cmd = "wget -qO- {url}".format(url=url) return execute_command(cmd)