From 4aee3a47d7be33732b3f586eb8748efea1113c77 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Fri, 14 Sep 2012 14:59:30 +0800 Subject: [PATCH] Disable check tag format when it don't map to OBS --- job_submitobs.py | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/job_submitobs.py b/job_submitobs.py index 85bbef9..789a17b 100755 --- a/job_submitobs.py +++ b/job_submitobs.py @@ -263,7 +263,6 @@ def main(): mygit = git.Git(prjdir) mygerrit = gerrit.Gerrit(GERRIT_HOSTNAME, GERRIT_USERNAME, GERRIT_SSHPORT) - checktagmsg = '' if GERRIT_EVENT_TYPE == "REF_UPDATED": tag = GERRIT_REFNAME[len('refs/tags/'):] else: @@ -279,11 +278,21 @@ def main(): print '\nThis change don\'t contain submit/*/* tag, exit now' end('success') + # check tag format tagcheck = check_tag_format(tag, mygit, mygerrit) + tagger = mygit.get_tag(tag) if not GERRIT_PATCHSET_REVISION: GERRIT_PATCHSET_REVISION = mygit.rev_parse(tag) commitinfo = mygit.get_commit_info(GERRIT_PATCHSET_REVISION) + + # parse git-obs-mapping to get OBS target project, exit if not map to any project + mapping = utils.parse_mapping('%s/git/%s/git-obs-mapping.xml' % (JENKINS_HOME, MAPPING_PRJ), GERRIT_PROJECT, GERRIT_BRANCH) + print 'git-obs-mapping:', mapping + if not mapping: + end('success') + + # post comment and send email if tag format check failed if tagcheck: print tagcheck mygerrit.review(commit = GERRIT_PATCHSET_REVISION, message = tagcheck['message']) @@ -299,9 +308,6 @@ def main(): mygit.checkout(tag) - mapping = utils.parse_mapping('%s/git/%s/git-obs-mapping.xml' % (JENKINS_HOME, MAPPING_PRJ), GERRIT_PROJECT, GERRIT_BRANCH) - print 'git-obs-mapping:', mapping - for target in mapping: mygit.clean('-fd') (obs_dst_prj, obs_stg_prj, obs_pkg) = target @@ -334,31 +340,31 @@ def main(): tarballdir = os.path.join(outdir, os.listdir(outdir)[0]) - if obs_stg_prj != obs_dst_prj: - tmppkg = obspkg.ObsPackage(tmpdir, obs_stg_prj, 'tmp', - apiurl = OBS_API_URL, oscrc = OBS_OSCRC_PATH) - if tmppkg.is_new_pkg(): - tmppkg.commit("Leave an empty package in this project to prevent OBS delete it automatically when all request from here are accepted.") + retry_count = 3 + while retry_count > 0: + try: + if obs_stg_prj != obs_dst_prj: + tmppkg = obspkg.ObsPackage(tmpdir, obs_stg_prj, 'tmp', + apiurl = OBS_API_URL, oscrc = OBS_OSCRC_PATH) + if tmppkg.is_new_pkg(): + tmppkg.commit("Leave an empty package in this project to prevent OBS delete it automatically when all request from here are accepted.") - print '\nCheckout %s/%s to local' % (obs_stg_prj, spec.name) - localpkg = obspkg.ObsPackage(tmpdir, obs_stg_prj, spec.name, - apiurl = OBS_API_URL, oscrc = OBS_OSCRC_PATH) - oscworkdir = localpkg.get_workdir() - localpkg.remove_all() - for myfile in os.listdir(tarballdir): - shutil.copy2(os.path.join(tarballdir, myfile), os.path.join(oscworkdir, myfile)) + print '\nCheckout %s/%s to local' % (obs_stg_prj, spec.name) + localpkg = obspkg.ObsPackage(tmpdir, obs_stg_prj, spec.name, + apiurl = OBS_API_URL, oscrc = OBS_OSCRC_PATH) + oscworkdir = localpkg.get_workdir() + localpkg.remove_all() + for myfile in os.listdir(tarballdir): + shutil.copy2(os.path.join(tarballdir, myfile), os.path.join(oscworkdir, myfile)) - # update changelog with git tag info - #update_changelog(localpkg, mygit, tag) + # update changelog with git tag info + #update_changelog(localpkg, mygit, tag) - # update gerritinfo with git info - #update_gerritinfo(localpkg, GERRIT_PROJECT, GERRIT_PATCHSET_REVISION) + # update gerritinfo with git info + #update_gerritinfo(localpkg, GERRIT_PROJECT, GERRIT_PATCHSET_REVISION) - localpkg.update_local() + localpkg.update_local() - retry_count = 3 - while retry_count > 0: - try: # submit local pkg to obs and create sr print '\nSubmit local pkg to obs...' localpkg.commit(msg) -- 2.7.4