From f4cb3719d539a8578c61855cf1856ccd6d2d8305 Mon Sep 17 00:00:00 2001 From: Hasan Wan Date: Thu, 2 Aug 2012 17:43:56 +0800 Subject: [PATCH] clean up the log output, delete the testing project from OBS after check Change-Id: Ibfeeb177d05e052e98f51c968cb91b0689bb96cb Signed-off-by: Hasan Wan --- buildcheck.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/buildcheck.py b/buildcheck.py index 458ce4a..15882bf 100755 --- a/buildcheck.py +++ b/buildcheck.py @@ -62,7 +62,7 @@ if __name__ == '__main__': mapping = utils.parse_mapping('%s/git/%s/git-obs-mapping.xml' % (JENKINS_HOME, mappingprj), GERRIT_PROJECT, GERRIT_BRANCH) - print "Project Mapping info: ", mapping + print "Project Mapping info: %s" %mapping for target in mapping: (obs_dest_prj, obs_stg_prj, obs_pkg) = target @@ -71,7 +71,6 @@ if __name__ == '__main__': if not obs_dest_prj: continue - print '--------------------' print "Call gbs command: ", "gbs -v rb -B %s -T %s %s" %(obs_dest_prj, buildcheck_project, prjdir) os.system("gbs rb -B %s -T %s %s" %(obs_dest_prj, buildcheck_project, prjdir)) @@ -83,16 +82,18 @@ if __name__ == '__main__': specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, prj) try: spec = gbp.rpm.parse_spec(specfile) - except GbpError, err: - msger.error('%s' % err) + except err: + print '%s' % err bs = buildservice.BuildService(apiurl=OBS_API_URL, oscrc=OBS_OSCRC_PATH) # Loop until no building status loop = True while loop: - time.sleep(10) + time.sleep(30) status = bs.get_results(buildcheck_project, spec.name) + if not status: + break for build_repo in status.keys(): if 'building' in status[build_repo].values(): loop = True @@ -100,13 +101,9 @@ if __name__ == '__main__': loop = False # We might need sometime to wait the 'finished' status change to final status - time.sleep(10) + time.sleep(10) status = bs.get_results(buildcheck_project, spec.name) - - print '========================================' - print "OBS Package Status" - print status - print '========================================' + print "OBS Package Status\n:", status msg='[BUILD CHECK RESULT] This change is built against OBS project %s: \n\n %-15s%-15s%-15s' %(obs_dest_prj, "repository", "arch", "result") @@ -114,15 +111,20 @@ if __name__ == '__main__': for arch in status[repo]: msg = msg + '\n\n %-15s%-15s%-15s' %(repo, arch, status[repo][arch]) if status[repo][arch] != 'succeeded': - buildlog_gz = "/tmp/buildlog-%s-%s-%s.log.gz" %(spec.name, arch, status[repo][arch]) + buildlog_gz = "%s/buildlog-%s-%s-%s.log.gz" %(WORKSPACE, spec.name, arch, status[repo][arch]) log=bs.getBuildLog(buildcheck_project, '%s/%s'%(repo,arch), spec.name) f = gzip.open(buildlog_gz, "wb") f.write(log) f.close() sendmail('[BUILD CHECK RESULT]: Your change for %s is failed to build against %s' %(GERRIT_PROJECT, obs_dest_prj), msg, 'no-replay@tz-testing-jenkins.bj.intel.com', '%s' %GERRIT_CHANGE_OWNER_EMAIL, attachment = buildlog_gz) - + print 'The log file %s is deleted' %(buildlog_gz) + os.remove(buildlog_gz) + if not status: + runner.show('%s %s %s,%s --message \'"%s"\'' % (gerritcmd, 'review', GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER, "[BUILD CHECK RESULT] The project %s is not ready for build, please contact the build systerm administrator")) + end(1) + + print 'The project %s is deleted on OBS' %(buildcheck_project) + bs.deleteProject(buildcheck_project) print msg runner.show('%s %s %s,%s --message \'"%s"\'' % (gerritcmd, 'review', GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER, msg)) - - end() -- 2.7.4