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:
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'])
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
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)