Skip to content
Snippets Groups Projects
Commit a0696bcf authored by Colin's avatar Colin
Browse files

Attempt fix

parent 6b387ed1
Branches
No related merge requests found
Pipeline #607 failed with stages
in 53 seconds
variables:
NEXUS_DEV_SEARCH_URL: "https://nexus-dev.unstable.life/service/rest/v1/search?repository=development&name=*.json"
NEXUS_DEV_URL: "https://nexus-dev.unstable.life/repository/development/"
NEXUS_DEV_SEARCH_URL: "https://nexus-dev.unstable.life/service/rest/v1/search?repository=development"
NEXUS_REPO: components-stable
NEXUS_DEPLOY_STABLE: 1
......@@ -12,7 +11,7 @@ include:
package:
stage: build
script: |
python3 ./download-components.py $NEXUS_DEV_SEARCH_URL $NEXUS_DEV_URL $COMPONENTS
python3 ./download-components.py $NEXUS_DEV_SEARCH_URL $COMPONENTS
zip artifact.zip ./*.zip ./*.json
echo "Packaged components into artifact.zip"
artifacts:
......
import urllib.request
import json
import sys
import os
def parse_page(data, components, force_promote):
for item in data['items']:
full_name = os.path.splitext(item['name'])[0]
if item['group'] == "/" and full_name != "components":
if force_promote or full_name in components:
download_url = item['assets'][0]['downloadUrl']
urllib.request.urlretrieve(download_url, item['name'])
print("Downloaded: " + item['name'])
def main():
print("Fetching components...")
# Components to promote
comps_to_promote = sys.argv[3:]
force_promote = False
comps_to_promote = sys.argv[2:]
if comps_to_promote[0] == "all":
force_promote = True
print("Attempting to promote: " + str(comps_to_promote))
source_search_url = sys.argv[1]
print("Source search URL: " + source_search_url)
source_repo_url = sys.argv[2]
print("Source repo URL: " + source_repo_url)
# Download each component from source repo
count = 0
with urllib.request.urlopen(source_search_url) as url:
count = count + 1
print("Loading page " + count)
data = json.load(url)
for item in data['items']:
if item['name'][:-5] in comps_to_promote:
# Download component metadata from source repo
download_url = source_repo_url + item['name']
urllib.request.urlretrieve(download_url, item['name'])
# Download component from source repo
download_url = source_repo_url + item['name'][:-5] + '.zip'
urllib.request.urlretrieve(download_url, item['name'][:-5] + '.zip')
print("Downloaded: " + item['name'][:-5])
comps_to_promote.remove(item['name'][:-5])
parse_page(data, comps_to_promote, force_promote)
while data['continuationToken']:
count = count + 1
print("Loading page " + count)
with urllib.request.urlopen(source_search_url + '&continuationToken=' + data['continuationToken']) as url:
data = json.load(url)
parse_page(data, comps_to_promote, force_promote)
if len(comps_to_promote) > 0:
print("Failed to download: " + str(comps_to_promote))
print("Done downloading components")
if __name__ == "__main__":
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment