Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.admin
Commits
214486a5
Commit
214486a5
authored
7 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Uploads files to the DAV server with a check
parent
4b9b2d78
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitlab/functions.sh
+22
-11
22 additions, 11 deletions
gitlab/functions.sh
with
22 additions
and
11 deletions
gitlab/functions.sh
+
22
−
11
View file @
214486a5
...
@@ -119,6 +119,14 @@ run_cmd() {
...
@@ -119,6 +119,14 @@ run_cmd() {
}
}
# Checks if a file exists on the remote location
# $1: Path to the file to check on the server
dav_exists
()
{
curl
--head
--silent
--location
${
DOCSERVER
}
/
${
1
}
|
grep
HTTP |
tail
-n
1 |
grep
-q
200
return
$?
}
# Uploads a file to our intranet location via curl
# Uploads a file to our intranet location via curl
# $1: Path to the file to upload (e.g. dist/myfile.whl)
# $1: Path to the file to upload (e.g. dist/myfile.whl)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
...
@@ -139,6 +147,20 @@ dav_upload() {
...
@@ -139,6 +147,20 @@ dav_upload() {
}
}
# Uploads a file to our intranet location via curl, if (and only if) it does
# not exist on the remote server
# $1: Path to the file to upload (e.g. dist/myfile.whl)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
dav_check_upload
()
{
local
remote_name
=
${
2
}
/
$(
basename
${
1
}
)
if
dav_exists
${
remote_name
}
;
then
log_info
"File
\`
${
remote_name
}
' already exists on the remote server (not uploading again)"
else
dav_upload
${
1
}
${
2
}
fi
}
# Creates a folder at our intranet location via curl
# Creates a folder at our intranet location via curl
# $1: Path of the folder to create (e.g. private-upload/docs/test-folder)
# $1: Path of the folder to create (e.g. private-upload/docs/test-folder)
# $2: which HTTP response code it should return instead of exit on (e.g. 405 means the folder already exists)
# $2: which HTTP response code it should return instead of exit on (e.g. 405 means the folder already exists)
...
@@ -244,17 +266,6 @@ dav_upload_folder() {
...
@@ -244,17 +266,6 @@ dav_upload_folder() {
}
}
# Checks if an array contains a value
# taken from here: https://stackoverflow.com/questions/3685970/check-if-an-array-contains-a-value
# Parameters: <value-to-check> <array-variable>
# Usage: "a string" "${array[@]}"
contains_element
()
{
local
e
for
e
in
"
${
@
:2
}
"
;
do
[[
"
$e
"
==
"
$1
"
]]
&&
return
0
;
done
return
1
}
if
[
-z
"
${
BOB_PACKAGE_VERSION
}
"
]
;
then
if
[
-z
"
${
BOB_PACKAGE_VERSION
}
"
]
;
then
if
[
!
-r
"version.txt"
]
;
then
if
[
!
-r
"version.txt"
]
;
then
log_error
"./version.txt does not exist - cannot figure out version number"
log_error
"./version.txt does not exist - cannot figure out version number"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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