Log the job name info when running test mode

When user runs 'jenkins-jobs test myjobs.yaml' only the xml
gets printed to screen but the xml doesn't contain any info
about the job name.  This logs the job name before showing
the xml snippet for each job.  Helps in debugging jobs when
using templates.

For example:

INFO:jenkins_jobs.builder:Job name:  foojob-py27-unit-master
<?xml version="1.0" encoding="utf-8"?>
<project>
  <actions/>
  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
  <keepDependencies>false</keepDependencies>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <concurrentBuild>false</concurrentBuild>
  <canRoam>true</canRoam>
  <properties/>
  <scm class="hudson.scm.NullSCM"/>
  <builders>
    <hudson.tasks.Shell>
      <command>git checkout master</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers/>
  <buildWrappers/>
</project>
..
..

Change-Id: Ibce45debd5fd6aa1a400e1cc3762846415ca2a75
This commit is contained in:
Khai Do 2015-03-12 10:14:40 -07:00
parent be8def7829
commit a8f7e4a98f

@ -818,6 +818,7 @@ class Builder(object):
if output:
if hasattr(output, 'write'):
# `output` is a file-like object
logger.info("Job name: %s", job.name)
logger.debug("Writing XML to '{0}'".format(output))
try:
output.write(job.output())