Create the build log in the artifact dir

This allows the jenkins master to receive the log file even if the build
script aborted. Before I was just copying the log file to the artifact
dir at the end of the script, which meant that jenkins only gets the log
when the script succeeds.
This commit is contained in:
Erik Johnson 2014-09-11 13:08:40 -05:00
parent a146a80034
commit e22c000d5c

View file

@ -92,10 +92,6 @@ def _init():
help='Location where build artifacts should be '
'placed, the jenkins master will grab all of '
'these. Default: %default')
path_group.add_option('--log-file',
dest='log_file',
default='/tmp/salt-buildpackage.log',
help='Log results to a file. Default: %default')
parser.add_option_group(path_group)
# This group should also consist of nothing but file paths, which will be
@ -155,6 +151,10 @@ def _init():
problems.append('Unable to create artifact directory {0}: {1}'
.format(opts.artifact_dir, exc))
# Create log file in the artifact dir so it is sent back to master if the
# job fails
opts.log_file = os.path.join(opts.artifact_dir, 'salt-buildpackage.log')
if problems:
_abort(problems)
@ -360,4 +360,3 @@ if __name__ == '__main__':
shutil.copy(artifact, opts.artifact_dir)
log.info('Copied {0} to artifact directory'.format(artifact))
log.info('Done!')
shutil.copy(opts.log_file, opts.artifact_dir)