Add getting logs from jobs
Related-Prod:PROD-36500
Change-Id: I4f8a999ceb03fe7a80f9bbf9a2d9252084ef95f1
diff --git a/tcp_tests/managers/drivetrain_manager.py b/tcp_tests/managers/drivetrain_manager.py
index f65892e..dbc5096 100644
--- a/tcp_tests/managers/drivetrain_manager.py
+++ b/tcp_tests/managers/drivetrain_manager.py
@@ -11,11 +11,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-
from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
from tcp_tests.utils import run_jenkins_job
from tcp_tests.utils import get_jenkins_job_stages
from tcp_tests import logger
+from tcp_tests.managers.jenkins import client
LOG = logger.logger
@@ -62,6 +62,11 @@
jenkins_url, jenkins_user, jenkins_pass = self.get_jenkins_creds(
tgt=jenkins_tgt)
+ jenkins = client.JenkinsClient(host=jenkins_url,
+ username=jenkins_user,
+ password=jenkins_pass)
+ build_number = jenkins.job_info(job_name)['nextBuildNumber']
+
job_result = run_jenkins_job.run_job(
host=jenkins_url,
username=jenkins_user,
@@ -83,6 +88,11 @@
.format(description=description,
stages='\n'.join(stages))
+ job_log = jenkins.get_build_output(job_name, build_number)
+
+ with open('tmp/' + job_name + str(build_number) + '.log', 'wb') as f:
+ f.write(job_log)
+
if job_result != 'SUCCESS':
LOG.warning("{0}\n{1}".format(description, '\n'.join(stages)))
return job_result, job_description