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
cb171f39
Commit
cb171f39
authored
7 years ago
by
André Anjos
Browse files
Options
Downloads
Plain Diff
Merge branch 'webdav-recursive-dirs' into 'master'
Webdav recursive dirs See merge request
!59
parents
a48a80b8
c51115d5
Branches
Branches containing commit
No related tags found
1 merge request
!59
Webdav recursive dirs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gitlab/before_docs.sh
+6
-0
6 additions, 0 deletions
gitlab/before_docs.sh
gitlab/functions.sh
+38
-1
38 additions, 1 deletion
gitlab/functions.sh
with
44 additions
and
1 deletion
gitlab/before_docs.sh
+
6
−
0
View file @
cb171f39
...
@@ -3,6 +3,12 @@
...
@@ -3,6 +3,12 @@
source
$(
dirname
${
0
}
)
/functions.sh
source
$(
dirname
${
0
}
)
/functions.sh
# if the docs will be uploaded to at least one place,
# make sure that the project folder will be available
if
[[
${#
DOC_UPLOADS
[@]
}
-gt
0
]]
;
then
dav_recursive_mkdir
"
${
DOC_SERVER_PREFIX
}
"
fi
# Deletes all existing dav folders that will be overwritten
# Deletes all existing dav folders that will be overwritten
for
k
in
"
${
DOC_UPLOADS
[@]
}
"
;
do
for
k
in
"
${
DOC_UPLOADS
[@]
}
"
;
do
dav_delete
"
${
k
}
"
dav_delete
"
${
k
}
"
...
...
This diff is collapsed.
Click to expand it.
gitlab/functions.sh
+
38
−
1
View file @
cb171f39
...
@@ -210,11 +210,19 @@ dav_upload() {
...
@@ -210,11 +210,19 @@ dav_upload() {
# 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)
dav_mkdir
()
{
dav_mkdir
()
{
local
code
=
$(
curl
--location
--silent
--fail
--write-out
"%{http_code}"
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
MKCOL
"
${
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
if
[[
${
code
}
==
*
204
||
${
code
}
==
*
201
]]
;
then
log_info
"curl: mkdir
${
DOCSERVER
}
/
${
1
}
"
log_info
"curl: mkdir
${
DOCSERVER
}
/
${
1
}
"
# if the return code was not a success, the function should usually treat it as an error.
# however, sometimes the codes must be treated more flexibly, e.g.:
# dav_recursive_mkdir wants the directory created *or* already existing,
# which means that a 405 (directory already exists) should not be treated as an error.
# other codes may also have similar consideration in the future.
elif
[[
"
${
code
}
"
==
"
$2
"
]]
;
then
return
"
${
code
}
"
else
else
log_error
"Curl command finished with an error condition (code=
${
code
}
):"
log_error
"Curl command finished with an error condition (code=
${
code
}
):"
curl
--location
--silent
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
MKCOL
"
${
DOCSERVER
}
/
${
1
}
"
curl
--location
--silent
--user
"
${
DOCUSER
}
:
${
DOCPASS
}
"
-X
MKCOL
"
${
DOCSERVER
}
/
${
1
}
"
...
@@ -223,6 +231,34 @@ dav_mkdir() {
...
@@ -223,6 +231,34 @@ dav_mkdir() {
}
}
# Creates a folder and all parent folders at a intranet location via curl (mkdir -p)
# $1: Path of a folder to guarantee to be writeable (e.g. private-upload/docs/bob/bob.admin)
dav_recursive_mkdir
()
{
log_info
"curl: mkdir -p
${
DOCSERVER
}
/
${
1
}
"
# split path into an array of path segments
# uses a subshell so setting the IFS doesnt mess up *this* shell
local
path_segments
=(
$(
IFS
=
/
read
-r
-A
arr
<<<
"
$1
"
;
echo
"
$arr
"
)
)
local
current_subpath
=
''
# loop through segments
for
seg
in
$path_segments
;
do
# append each segment to the current subpath
current_subpath
=
"
${
current_subpath
}${
seg
}
/"
# make sure the current subpath folder is created
local
response
# a 405 exit code is returned when the folder already exists
response
=
$(
dav_mkdir
"
$current_subpath
"
405
)
if
[[
"
${
response
}
"
==
"405"
]]
;
then
log_info
"Directory
${
current_subpath
}
already exists."
else
log_info
"Directory
${
current_subpath
}
did not exist and was created."
fi
done
}
# Deletes a file/folder from our intranet location via curl
# Deletes a file/folder from our intranet location via curl
# $1: Path to the file/folder to delete (e.g. dist/myfile.whl)
# $1: Path to the file/folder to delete (e.g. dist/myfile.whl)
dav_delete
()
{
dav_delete
()
{
...
@@ -435,5 +471,6 @@ fi
...
@@ -435,5 +471,6 @@ fi
if
[[
-n
"
${
CI_COMMIT_TAG
}
"
&&
"
${
IS_MASTER
}
"
==
"true"
]]
;
then
if
[[
-n
"
${
CI_COMMIT_TAG
}
"
&&
"
${
IS_MASTER
}
"
==
"true"
]]
;
then
DOC_UPLOADS+
=(
"
${
DOC_SERVER_PREFIX
}
/stable/"
)
DOC_UPLOADS+
=(
"
${
DOC_SERVER_PREFIX
}
/stable/"
)
fi
fi
unset
DOC_SERVER_PREFIX
export_env DOC_SERVER_PREFIX
check_env DOC_UPLOADS
check_env DOC_UPLOADS
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