def get_repostatus(self):
return self.bs.getRepoState(self.project)
+ def is_published(self):
+ try:
+ return set(self.get_repostatus().values()) == set(['published'])
+ except:
+ return False
+
def get_abs_repopath(self):
# FIXME: hard code here
return "/srv/obs/repos/%s" %(self.project.replace(":", ":/"))
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
-"""This script will do policy check when patch is created in gerrit.
+"""This job will help submit the changes to a temporary OBS project when SR created.
"""
from common.envparas import export
export(envparas, locals())
-GIT_URL = 'git://%s' % (GERRIT_HOSTNAME)
+GIT_URL = 'ssh://%s@%s:%s' % (GERRIT_USERNAME, GERRIT_HOSTNAME, GERRIT_SSHPORT)
-
-
if __name__ == '__main__':
print '---[JOB STARTED]----------------------------------------'
from common.buildservice import BuildService, TempBuildService
import repomaker
import base64
+import time
from images import generate_images_info, get_ks_list, set_relative_uri
server_conf.repos_conf = temp_conf_fn
# Disable the project build to save resource
tempbuild=TempBuildService(temp_repo_define_dict['Project'], OBS_API_URL, PATH_OSCRC)
+ time.sleep(10)
+ assert(tempbuild.is_published())
tempbuild.disable_build(temp_repo_define_dict['SandboxOf'], OBS_USERNAME)
builds_dir = server_conf.builds
--- /dev/null
+#!/usr/bin/env python
+# vim: ai ts=4 sts=4 et sw=4
+
+"""This script will cleanup the temporary project/repo when SR closed.
+"""
+
+from common.envparas import export
+from common.buildservice import BuildService
+import os
+
+envparas = ['JENKINS_HOME',
+ 'WORKSPACE',
+ 'GIT_PROJECT',
+ 'GIT_TAG',
+ 'OBS_REQ_PRJ_SRC',
+ 'OBS_REQ_PRJ',
+ 'OBS_REQ_PKG',
+ 'OBS_REQ_ID',
+ 'OBS_API_URL',
+ 'PATH_BUILDS',
+ 'PATH_OSCRC',
+ 'OBS_OSCRC_PATH',
+ 'COMMITID',
+ 'OBS_REQ_WHO',
+ 'GERRIT_HOSTNAME',
+ 'GERRIT_USERNAME',
+ 'GERRIT_SSHPORT',
+ 'GIT_CACHE_DIR']
+
+export(envparas, locals())
+
+GIT_URL = 'ssh://%s@%s:%s' % (GERRIT_USERNAME, GERRIT_HOSTNAME, GERRIT_SSHPORT)
+
+
+def search_published_repo(repo_path_base, project, sr_id):
+
+ reviewrepo_base = os.path.join(repo_path_base,'pre-release', project)
+ if os.path.isdir(repo_path_base):
+ for dir_name in os.listdir(reviewrepo_base):
+ if dir_name.endswith("sr.%s" %sr_id):
+ return os.path.join(reviewrepo_base, dir_name)
+ else:
+ print "WARN: reviewrepo %s doesn't exist" %reviewrepo_base
+
+if __name__ == '__main__':
+
+ print '---[JOB STARTED]----------------------------------------'
+
+
+ obs_project = "%s:prerelease:%s:%s" %( OBS_REQ_PRJ, OBS_REQ_ID, OBS_REQ_PKG)
+ bs = BuildService(OBS_API_URL, PATH_OSCRC)
+ bs.deleteProject(obs_project)
+ print "OBS Project %s deleted" %obs_project
+
+ reviewrepo_path = search_published_repo(PATH_BUILDS, OBS_REQ_PKG, OBS_REQ_ID)
+ if reviewrepo_path:
+ print "Removing temporary repo: %s" %reviewrepo_path
+ os.system("rm -rf %s" %reviewrepo_path)
+ else:
+ print "WARN: Temporary %s has been removed" %reviewrepo_path