-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathfetch_assets
More file actions
executable file
·60 lines (49 loc) · 1.38 KB
/
fetch_assets
File metadata and controls
executable file
·60 lines (49 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
curdir=$(dirname $0)
ce_project="gitlab-foss"
ee_project="gitlab"
group_name="gitlab-org"
if [ "${ASSET_REGISTRY}" = "dev.gitlab.org:5005" ]
then
group_name="gitlab"
ce_project="gitlabhq"
ee_project="gitlab-ee"
fi
if [[ -n "${TOP_UPSTREAM_SOURCE_PROJECT}" && "${TOP_UPSTREAM_SOURCE_PROJECT}" =~ gitlab-org/(security/)?gitlab(-foss)?$ ]]
then
project_path="${TOP_UPSTREAM_SOURCE_PROJECT}"
elif ${curdir}/is_gitlab_ee.sh
then
project_path="${group_name}/${ee_project}"
else
project_path="${group_name}/${ce_project}"
fi
if ${curdir}/is_gitlab_ee.sh
then
assets_image="${project_path}/gitlab-assets-ee"
else
assets_image="${project_path}/gitlab-assets-ce"
fi
gitlab_version=$(echo "${1}" | awk '
{
gsub(/[^a-z0-9]/, "-")
gsub(/(^-+|-+$)/, "")
print substr($0, 1, 63);
}
')
if [ -z "$gitlab_version" ]
then
echo "error generating gitlab_version from ${1} "
exit 1
fi
docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
assets_image_name="${ASSET_REGISTRY}/${assets_image}:${gitlab_version}"
# In case the image hasn't been created yet. Keep trying until the pipeline times out
interval=30
while ! docker pull "${assets_image_name}"
do
echo "${assets_image_name} is not available yet. Will retry in ${interval} seconds"
sleep ${interval}
done
docker create --name asset_cache "${assets_image_name}"
docker cp asset_cache:/assets ${ASSET_PATH}