From: Junghyun Kim Date: Tue, 24 Jan 2017 02:13:55 +0000 (+0900) Subject: Use PATH_REPO_BASE instead of IMG_SYNC_DEST_BASE X-Git-Tag: submit/trunk/20190927.012743~561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56c4614b67ef38846a972a35e6f935ad49a138ce;p=services%2Fjenkins-scripts.git Use PATH_REPO_BASE instead of IMG_SYNC_DEST_BASE Since make_dep_graph is execued on jenkins slave 'download', it does not need to use 'rsync::'. Change-Id: I7a1db6837d6131ebad1f1e98f75776032c2425f1 Signed-off-by: Junghyun Kim --- diff --git a/job_make_dep_graph.py b/job_make_dep_graph.py index cad7bca..719e02d 100644 --- a/job_make_dep_graph.py +++ b/job_make_dep_graph.py @@ -20,7 +20,7 @@ import re import os import sys -import shutil +import shutil import subprocess from common.buildtrigger import trigger_info @@ -36,13 +36,13 @@ class LocalError(Exception): pass def create_build_progress_dep_graph(build, obs_project, content): - sync_out_dir = os.path.join(os.getenv('WORKSPACE'), 'outdir') + bp_id = content.get("build_project_id") + sync_out_dir = os.path.join(os.getenv('WORKSPACE'), bp_id) + sync_dest_base = os.getenv('PATH_REPO_BASE') - sync_dest_parent = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), + sync_dest = os.path.join(sync_dest_base, ".dep_graph", obs_project) - sync_dest = os.path.join(sync_dest_parent, - content.get("build_project_id")) print "sync_dest = %s" % sync_dest @@ -51,26 +51,17 @@ def create_build_progress_dep_graph(build, obs_project, content): #make directories if not existed. os.makedirs(sync_out_dir) - sync(sync_out_dir, os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - ".dep_graph")) - - sync(sync_out_dir, os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - ".dep_graph", obs_project)) - - sync(sync_out_dir, os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - ".dep_graph", obs_project, - content.get("build_project_id"))) # copy vis and dep_graph dirs. - vis_dir = os.path.join(os.getenv("WORKSPACE"), "jenkins-scripts/vis") - vis_sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - ".dep_graph/vis") - sync(vis_dir, vis_sync_dest) + vis_sync_dest = os.path.join(sync_dest_base, ".dep_graph/vis") + if not os.path.exists(vis_sync_dest): + vis_dir = os.path.join(os.getenv("WORKSPACE"), "jenkins-scripts/vis") + sync(vis_dir, vis_sync_dest) - dep_graph_dir = os.path.join(os.getenv("WORKSPACE"), "jenkins-scripts/dep_graph") - dep_graph_sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - ".dep_graph/dep_graph") - sync(dep_graph_dir, dep_graph_sync_dest) + dep_graph_sync_dest = os.path.join(sync_dest_base, ".dep_graph/dep_graph") + if not os.path.exists(dep_graph_sync_dest): + dep_graph_dir = os.path.join(os.getenv("WORKSPACE"), "jenkins-scripts/dep_graph") + sync(dep_graph_dir, dep_graph_sync_dest) vis_dir = "../../../../vis" dep_graph_dir = "../../../../dep_graph" @@ -96,7 +87,7 @@ def create_build_progress_dep_graph(build, obs_project, content): os.getenv("OBS_API_USERNAME"), os.getenv("OBS_API_PASSWD"), obs_project, - repo, + repo, arch) set_mysql_environment(os.getenv("BUILDMONITOR_IP"), os.getenv("BUILDMONITOR_USER"), @@ -104,19 +95,21 @@ def create_build_progress_dep_graph(build, obs_project, content): os.getenv("BUILDMONITOR_NAME"), "0") - make_dep_graph(filename, graph_dest_dir, + make_dep_graph(filename, graph_dest_dir, vis_dir, dep_graph_dir, template_filename, packages_to_be_built) # sync to donwload server + if os.path.exists(sync_dest): + shutil.rmtree(sync_dest) + os.makedirs(sync_dest) sync(sync_out_dir, sync_dest) - # sync latest link - latest_parent = os.path.join(sync_out_dir, "link") - os.makedirs(latest_parent) - latest = os.path.join(latest_parent, "latest") + # make latest link + latest = os.path.join(sync_dest, "latest") + if os.path.exists(latest): + os.unlink(latest) os.symlink(content.get("build_project_id"), latest) - sync(latest_parent, sync_dest_parent) def create_build_progress_dep_graph_post(build, obs_project, backenddb, content): print "creating build_progress_dep_graph..." @@ -139,7 +132,7 @@ def create_build_progress_dep_graph_post(build, obs_project, backenddb, content) build_id_arr=snapshot.build_id.split('.'); build_id_arr[-1] = str(int(build_id_arr[-1])+1); new_build_id = '.'.join(build_id_arr) - sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), + sync_dest = os.path.join(repo_base, snapshot.dir, new_build_id); print "sync_dest = %s" % sync_dest @@ -175,7 +168,7 @@ def create_build_progress_dep_graph_post(build, obs_project, backenddb, content) # first sync to make just directory. sync(sync_out_dir, sync_dest) - graph_root_dir = os.path.join(sync_out_dir, "builddata", + graph_root_dir = os.path.join(sync_out_dir, "builddata", "depends", "build_progress_dep_graph") print "graph_root_dir = %s" % graph_root_dir @@ -206,10 +199,10 @@ def create_build_progress_dep_graph_post(build, obs_project, backenddb, content) os.getenv("OBS_API_USERNAME"), os.getenv("OBS_API_PASSWD"), obs_project, - repo, + repo, arch) - make_dep_graph(filename, graph_dest_dir, + make_dep_graph(filename, graph_dest_dir, vis_dir, dep_graph_dir, template_filename) # sync to donwload server @@ -240,9 +233,9 @@ def create_build_progress_dep_graph_prerelease(build, obs_project, obs_linked_pr except SnapshotError, err: raise LocalError("Error getting prerelease info: %s" % str(err)) - sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), + sync_dest = os.path.join(repo_base, prerelease.path, prerelease.build_id); - graph_root_dir = os.path.join(sync_out_dir, "builddata", + graph_root_dir = os.path.join(sync_out_dir, "builddata", "depends", "build_progress_dep_graph") print "graph_root_dir = %s" % graph_root_dir print "packages_to_be_built = %s" % packages_to_be_built @@ -275,27 +268,29 @@ def create_build_progress_dep_graph_prerelease(build, obs_project, obs_linked_pr os.getenv("OBS_API_USERNAME"), os.getenv("OBS_API_PASSWD"), obs_project, - repo, + repo, arch) - make_dep_graph(filename, graph_dest_dir, - vis_dir, dep_graph_dir, template_filename, + make_dep_graph(filename, graph_dest_dir, + vis_dir, dep_graph_dir, template_filename, packages_to_be_built) - + # sync to donwload server sync(sync_out_dir, sync_dest) def create_build_dep_graph(build, obs_project, backenddb, content): sync_out_dir = os.path.join(os.getenv('WORKSPACE'), - 'outdir') + 'dep_graph') - sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), - content['repo_path']) + sync_dest = os.path.join(os.getenv('PATH_REPO_BASE'), + content['repo_path'], + "build_data", + "depends") + print "sync_dest = %s" % sync_dest - os.makedirs(os.path.join(sync_out_dir,'builddata','depends')) template_filename="jenkins-scripts/common/dep_graph.php.template" - graph_root_dir=os.path.join(sync_out_dir,'builddata','depends','dep_graph') + graph_root_dir=os.path.join(sync_out_dir) os.makedirs(graph_root_dir) packages_to_be_built = [] @@ -338,14 +333,17 @@ def create_build_dep_graph(build, obs_project, backenddb, content): print "packages_to_be_built: ", packages_to_be_built print "built_packages: ", built_packages - make_dep_graph(filename, graph_dest_dir, + make_dep_graph(filename, graph_dest_dir, vis_dir, dep_graph_dir, template_filename, packages_to_be_built, built_packages) else: - make_dep_graph(filename, graph_dest_dir, + make_dep_graph(filename, graph_dest_dir, vis_dir, dep_graph_dir, template_filename) - # sync to donwload server + # sync to download server + if os.path.exists(sync_dest): + shutil.rmtree(sync_dest) + os.makedirs(sync_dest) sync(sync_out_dir, sync_dest) def main():