From d6b49049c108728635c29de1354a11130bc3c26c Mon Sep 17 00:00:00 2001 From: Yonghee Han Date: Tue, 4 Apr 2017 15:36:51 +0900 Subject: [PATCH] Feature Request: Update NuGet Private package configuration : NUGET_SOURCE_PRIVATE Change-Id: I8862875786e0e60ef06a05c68cd95beb2e99480a --- job_update_nuget.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/job_update_nuget.py b/job_update_nuget.py index 084c06f..b6c6de0 100755 --- a/job_update_nuget.py +++ b/job_update_nuget.py @@ -45,9 +45,13 @@ def nuget_push(nuget_exe, nuget_source, nupkg, tmpdir): cmd = '%s push %s -Source %s' % (nuget_exe, nupkg, nuget_source) return execute(cmd, tmpdir) -def extract_rpms(repodir): +def extract_rpms(repodir, private=False): """ Extract rpms """ - ngrpms = glob.glob(os.path.join(repodir, '*-nuget-*.rpm')) + if private: + ngrpms = glob.glob(os.path.join(repodir, '*-nuget-private-[0-9]*.rpm')) + else: + ngrpms = glob.glob(os.path.join(repodir, '*-nuget-[0-9]*.rpm')) + tmpdir = tempfile.mkdtemp(prefix = 'nuget') for rpm in ngrpms: execute('rpm2cpio %s | cpio -idmv' % rpm, tmpdir) @@ -80,10 +84,12 @@ def main(): nuget_exe = "mono %s/jenkins-scripts/scripts/nuget.exe" %(os.getenv('WORKSPACE')) nuget_source = os.getenv("NUGET_SOURCE") + nuget_source_private = os.getenv("NUGET_SOURCE_PRIVATE") nuget_apikey = os.getenv("NUGET_APIKEY") # Initialize NuGet nuget_init(nuget_exe, nuget_source, nuget_apikey) + nuget_init(nuget_exe, nuget_source_private, nuget_apikey) if os.getenv('IMG_SYNC_DEST_BASE'): destdir = os.path.join(os.getenv('WORKSPACE'), @@ -114,13 +120,18 @@ def main(): print 'cmd = %s' %(cmd) subprocess.call(cmd, shell=True) + # Push .nupkg files in -nuget-*.rpm tmpdir = extract_rpms(destdir) print tmpdir - # Push .nupkg files in tmpdir to NuGet server push_nuget_files(nuget_exe, nuget_source, tmpdir) - # Cleanup tmpdir shutil.rmtree(tmpdir) + # Push .nupkg files in -nuget-private-*.rpm + tmpdir_priv = extract_rpms(destdir, private=True) + print tmpdir_priv + push_nuget_files(nuget_exe, nuget_source_private, tmpdir_priv) + shutil.rmtree(tmpdir_priv) + else: base_path = os.getenv('PATH_REPO_BASE') @@ -138,14 +149,18 @@ def main(): arch ) print "repo arch path = %s" %repo_arch_path - # Extract *-nuget-*.rpm files to tmpdir + # Push .nupkg files in -nuget-*.rpm tmpdir = extract_rpms(repo_arch_path) print tmpdir - # Push .nupkg files in tmpdir to NuGet server push_nuget_files(nuget_exe, nuget_source, tmpdir) - # Cleanup tmpdir shutil.rmtree(tmpdir) + # Push .nupkg files in -nuget-private-*.rpm + tmpdir_priv = extract_rpms(repo_arch_path, private=True) + print tmpdir_priv + push_nuget_files(nuget_exe, nuget_source_private, tmpdir_priv) + shutil.rmtree(tmpdir_priv) + print '---[JOB ENDED]---------------------------' return 0 -- 2.7.4