Add getting logs from jobs
Related-Prod:PROD-36500

Change-Id: I4f8a999ceb03fe7a80f9bbf9a2d9252084ef95f1
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
index 41c95fe..c7c919c 100644
--- a/tcp_tests/tests/system/test_cvp_pipelines.py
+++ b/tcp_tests/tests/system/test_cvp_pipelines.py
@@ -207,6 +207,9 @@
             ntp_skipped_nodes = ''
 
         job_name = 'cvp-sanity'
+        server = jenkins.Jenkins(jenkins_url, jenkins_user, jenkins_pass)
+        build_number = server.get_job_info(job_name)['nextBuildNumber']
+
         skipped_packages = ("python-setuptools,"
                             "python-pkg-resources,xunitmerge,"
                             "python-gnocchiclient, "
@@ -250,7 +253,8 @@
         # Download XML report
         show_step(4)
         destination_name = os.path.join(settings.LOGS_DIR,
-                                        "cvp_sanity_results.xml")
+                                        "tmp/" + job_name + "_"
+                                        + str(build_number) + "_results.xml")
         # Do not fail the test case when the job is failed, but
         # artifact with the XML report is present in the job.
         try:
@@ -259,8 +263,26 @@
                 username=jenkins_user,
                 password=jenkins_pass,
                 job_name=job_name,
-                build_number='lastBuild',
-                artifact_path='validation_artifacts/cvp-sanity_report.xml',
+                build_number=build_number,
+                artifact_path='validation_artifacts/' + job_name
+                              + '_report.xml',
+                destination_name=destination_name)
+        except jenkins.NotFoundException:
+            raise jenkins.NotFoundException("{0}\n{1}".format(
+                description, '\n'.join(stages)))
+
+        destination_name = os.path.join(settings.LOGS_DIR,
+                                        "tmp/" + job_name + "_"
+                                        + str(build_number) + "_full.log")
+
+        try:
+            get_jenkins_job_artifact.download_artifact(
+                host=jenkins_url,
+                username=jenkins_user,
+                password=jenkins_pass,
+                job_name=job_name,
+                build_number=build_number,
+                artifact_path='validation_artifacts/full.log',
                 destination_name=destination_name)
         except jenkins.NotFoundException:
             raise jenkins.NotFoundException("{0}\n{1}".format(
@@ -370,6 +392,9 @@
         jenkins_build_timeout = 50 * 60
 
         job_name = 'cvp-stacklight'
+        server = jenkins.Jenkins(jenkins_url, jenkins_user, jenkins_pass)
+        build_number = server.get_job_info(job_name)['nextBuildNumber']
+
         job_parameters = {
             "EXTRA_PARAMS": """
             envs:
@@ -406,7 +431,8 @@
         # Download XML report
         show_step(4)
         destination_name = os.path.join(settings.LOGS_DIR,
-                                        "stacklight_report.xml")
+                                        "tmp/" + job_name + "_"
+                                        + str(build_number) + "_results.xml")
         # Do not fail the test case when the job is failed, but
         # artifact with the XML report is present in the job.
         try: