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
99733b39
Commit
99733b39
authored
7 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Simplify logging on curl uploads
parent
88aa868f
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
+7
-14
7 additions, 14 deletions
gitlab/functions.sh
with
7 additions
and
14 deletions
gitlab/functions.sh
+
7
−
14
View file @
99733b39
...
...
@@ -192,8 +192,6 @@ setup_deploy() {
# $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_upload
()
{
log_info
"curl:
${
1
}
->
${
DOCSERVER
}
/
${
2
}
..."
if
[
!
-e
$1
]
;
then
log_error
"File
\`
${
1
}
\'
does not exist on the local disk"
exit
1
...
...
@@ -201,7 +199,7 @@ dav_upload() {
local
code
=
`
curl
--location
--silent
--fail
--write-out
"%{http_code}"
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
--upload-file
${
1
}
${
DOCSERVER
}
/
${
2
}
`
if
[[
${
code
}
==
*
204
||
${
code
}
==
*
201
]]
;
then
log_info
"
Successfully uploaded
${
1
}
with curl
"
log_info
"
curl: cp
${
1
}
->
${
DOCSERVER
}
/
${
2
}
...
"
else
log_error
"Curl command finished with an error condition (code=
${
code
}
):"
curl
--location
--silent
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
--upload-file
${
1
}
${
DOCSERVER
}
/
${
2
}
...
...
@@ -213,12 +211,10 @@ dav_upload() {
# Creates a folder at our intranet location via curl
# $1: Path of the folder to create (e.g. private-upload/docs/test-folder)
dav_mkdir
()
{
log_info
"curl: MKDIR
${
DOCSERVER
}
/
${
1
}
..."
local
code
=
$(
curl
--location
--silent
--fail
--write-out
"%{http_code}"
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
MKCOL
"
${
DOCSERVER
}
/
${
1
}
"
)
if
[[
${
code
}
==
*
204
||
${
code
}
==
*
201
]]
;
then
log_info
"
Successfully created
${
1
}
with curl
"
log_info
"
curl: mkdir
${
DOCSERVER
}
/
${
1
}
"
else
log_error
"Curl command finished with an error condition (code=
${
code
}
):"
curl
--location
--silent
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
MKCOL
"
${
DOCSERVER
}
/
${
1
}
"
...
...
@@ -230,20 +226,19 @@ dav_mkdir() {
# Deletes a file/folder from our intranet location via curl
# $1: Path to the file/folder to delete (e.g. dist/myfile.whl)
dav_delete
()
{
log_info
"curl:
EXISTS
${
DOCSERVER
}
/
${
1
}
?"
log_info
"curl:
exists
${
DOCSERVER
}
/
${
1
}
?"
# checks if the directory exists before trying to remove it (use --head)
local
code
=
$(
curl
--location
--silent
--fail
--write-out
"%{http_code}"
--head
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
"
${
DOCSERVER
}
/
$1
"
)
if
[[
${
code
}
==
*
404
]]
;
then
log_info
"Directory
$1
does not exist. Skipping deletion"
log_info
"Directory
${
DOCSERVER
}
/
$1
does not exist. Skipping deletion"
return
0
fi
log_info
"curl: DELETE
${
DOCSERVER
}
/
${
1
}
..."
code
=
$(
curl
--location
--silent
--fail
--write-out
"%{http_code}"
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
DELETE
"
${
DOCSERVER
}
/
$1
"
)
if
[[
${
code
}
==
*
204
||
${
code
}
==
*
201
]]
;
then
log_info
"
Successfully deleted
${
DOCSERVER
}
/
${
1
}
with curl
"
log_info
"
curl: rm -rf
${
DOCSERVER
}
/
${
1
}
"
else
log_error
"Curl command finished with an error condition (code=
${
code
}
):"
curl
--location
--silent
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
DELETE
"
${
DOCSERVER
}
/
$1
"
...
...
@@ -256,7 +251,7 @@ dav_delete() {
# $1: Path to the folder to upload (e.g. test-folder/)
# $2: Path on the server to upload to (e.g. private-upload/docs/test/ to put contents of test-folder/ in test/)
dav_upload_folder
()
{
log_info
"curl:
${
1
}
->
${
DOCSERVER
}
/
${
2
}
..."
log_info
"curl:
cp -r
${
1
}
->
${
DOCSERVER
}
/
${
2
}
..."
if
[
!
-e
$1
]
;
then
log_error
"Directory
\`
${
1
}
\'
does not exist on the local disk"
...
...
@@ -268,7 +263,7 @@ dav_upload_folder() {
# with the server path prefix ('private-upload/docs/test/')
# to make something like '../folder1/folder2/folder-to-upload/test.txt'
# into 'private-upload/docs/test.txt'
local
server_path
=
"
${
fname
/
$1
/
$2
}
"
local
server_path
=
"
${
fname
/
$1
\/
/
$2
}
"
# if its a file...
if
[[
-f
"
${
fname
}
"
]]
;
then
...
...
@@ -278,8 +273,6 @@ dav_upload_folder() {
# if its a dir, create the dir
dav_mkdir
"
${
server_path
}
"
fi
log_info
"Successfully copied folder
${
1
}
with curl"
done
}
...
...
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