Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Component Promotion Tool
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Flashpoint
Component Promotion Tool
Commits
a0696bcf
Commit
a0696bcf
authored
2 years ago
by
Colin
Browse files
Options
Downloads
Patches
Plain Diff
Attempt fix
parent
6b387ed1
Branches
Branches containing commit
No related merge requests found
Pipeline
#607
failed with stages
in 53 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-3
2 additions, 3 deletions
.gitlab-ci.yml
download-components.py
+25
-16
25 additions, 16 deletions
download-components.py
with
27 additions
and
19 deletions
.gitlab-ci.yml
+
2
−
3
View file @
a0696bcf
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
:
...
...
This diff is collapsed.
Click to expand it.
download-components.py
+
25
−
16
View file @
a0696bcf
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__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment