Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitLab Drupal CI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Docker
GitLab Drupal CI
Commits
56012dd0
Commit
56012dd0
authored
2 years ago
by
jurgenhaas
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'main'
Merging develop into main See merge request
!15
parents
69a9bbb8
04a85149
Branches
Branches containing commit
Tags
v2.2.24
Tags containing commit
1 merge request
!15
Merging develop into main
Pipeline
#526366
passed
2 years ago
Stage: build
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+5
-0
5 additions, 0 deletions
.gitlab-ci.yml
bin/download
+142
-0
142 additions, 0 deletions
bin/download
with
147 additions
and
0 deletions
.gitlab-ci.yml
+
5
−
0
View file @
56012dd0
include
:
-
project
:
gitlab-ci-cd/general
ref
:
main
file
:
'
/tagrelease.yml'
variables
:
VERSION
:
${CI_COMMIT_TAG}
...
...
This diff is collapsed.
Click to expand it.
bin/download
0 → 100755
+
142
−
0
View file @
56012dd0
#!/bin/bash
case
"
$1
"
in
db
)
mode
=
CollectDatabase
;;
files
)
mode
=
CollectFiles
;;
*
)
echo
"Provide either db or files as a first argument!"
exit
1
;;
esac
branch
=
main
if
[[
"x
$2
"
!=
"x"
]]
;
then
branch
=
$2
fi
export
DEBUG
=
no
function
gitlab
()
{
EXPECTED
=
$1
METHOD
=
$2
REQUEST
=
$3
shift
3
if
[[
"
${
DEBUG
}
"
==
"yes"
]]
;
then
echo
curl
--write-out
"
\n
HTTP-Code:%{http_code}"
-X
"
$METHOD
"
-s
-H
"Private-Token:
${
GITLAB_PRIVATE_TOKEN
}
"
"
${
GITLAB_URL
}
"
/api/v4/
"
$REQUEST
"
"
$@
"
fi
output
=
"
$(
curl
--write-out
"
\n
HTTP-Code:%{http_code}"
-X
"
$METHOD
"
-s
-H
"Private-Token:
${
GITLAB_PRIVATE_TOKEN
}
"
"
${
GITLAB_URL
}
"
/api/v4/
"
$REQUEST
"
"
$@
"
)
"
result
=
"
$(
echo
"
$output
"
|
grep
"{"
)
"
code
=
"
$(
echo
"
$output
"
|
grep
-m
1
"HTTP-Code:"
|
cut
-d
:
-f2
)
"
if
[[
$code
-eq
$EXPECTED
]]
;
then
return
fi
echo
$output
echo
"
$METHOD
request to
$REQUEST
did not succeed! Responds with code
$code
instead of
$EXPECTED
"
exit
99
}
function
isNumeric
()
{
re
=
'^[0-9]+$'
if
[[
$1
=
~
$re
]]
;
then
return
0
fi
return
1
}
function
parseUrl
()
{
# extract the protocol
proto
=
"
$(
echo
"
$1
"
|
grep
:// |
sed
-e
's,^\(.*://\).*,\1,g'
)
"
# remove the protocol
url
=
"
${
1
/
$proto
/
}
"
# extract the user (if any)
user
=
"
$(
echo
"
$url
"
|
grep
@ |
cut
-d
@
-f1
)
"
# extract the host and port
hostport
=
"
$(
echo
"
${
url
/
$user
@/
}
"
|
cut
-d
/
-f1
)
"
# by request host without port
# shellcheck disable=SC2001
host
=
"
$(
echo
"
$hostport
"
|
sed
-e
's,:.*,,g'
)
"
# by request - try to extract the port
port
=
"
$(
echo
"
$hostport
"
|
sed
-e
's,^.*:,:,g'
-e
's,.*:\([0-9]*\).*,\1,g'
-e
's,[^0-9],,g'
)
"
# extract the path (if any)
path
=
"
$(
echo
"
$url
"
|
sed
-e
's,:,/,g'
|
grep
/ |
cut
-d
/
-f2-
)
"
}
if
[[
-n
${
CI_SERVER_HOST
}
]]
;
then
GITLAB_URL
=
https://
$CI_SERVER_HOST
fi
if
[[
"x
${
GITLAB_URL
}
"
==
"x"
]]
;
then
echo
"Missing GITLAB_URL environment variable, should be set to e.g. https://gitlab.lakedrops.com"
exit
3
fi
if
[[
"x
${
GITLAB_PRIVATE_TOKEN
}
"
==
"x"
]]
;
then
echo
"Missing GITLAB_PRIVATE_TOKEN environment variable"
exit
4
fi
parseUrl
"
$GITLAB_URL
"
host1
=
$host
parseUrl
"
$(
git config remote.origin.url
)
"
host2
=
$host
if
[[
"
$host1
"
!=
"
$host2
"
]]
;
then
echo
"This repository doesn't match the provided GitLab instance"
exit
5
fi
if
[[
-n
${
CI_PROJECT_ID
}
]]
;
then
PRJID
=
$CI_PROJECT_ID
else
echo
"Find project ID from remote URL ..."
# shellcheck disable=SC2001
path
=
"
$(
echo
"
$path
"
|
sed
-e
's,\..*,,g'
)
"
gitlab 200 GET
"projects?search_namespaces=1&search=
$path
"
PRJID
=
$(
echo
"
$result
"
| jq
-r
.[0].
"id"
)
if
[[
"a
${
PRJID
}
a"
==
"aa"
]]
;
then
echo
"No project found"
exit
6
fi
if
[[
$(
isNumeric
"
$PRJID
"
)
-eq
1
]]
;
then
echo
"Can not find project ID"
exit
6
fi
fi
echo
"Find pipeline trigger token ..."
gitlab 200 GET projects/
"
$PRJID
"
/triggers
TRIGGERTOKEN
=
$(
echo
"
$result
"
| jq
-r
.[0].
"token"
)
if
[[
"a
${
TRIGGERTOKEN
}
a"
==
"aa"
]]
;
then
echo
"No trigger token found"
exit
7
fi
echo
"Trigger pipeline ..."
gitlab 201 POST projects/
"
$PRJID
"
/trigger/pipeline
--data
"token=
$TRIGGERTOKEN
"
--data
"ref=
${
branch
}
"
--data
"variables[TRIGGERTASK]=
$mode
"
PIPELINEID
=
$(
echo
"
$result
"
| jq
-r
.
"id"
)
PIPELINESTATUS
=
$(
echo
"
$result
"
| jq
-r
.
"status"
)
while
[
$PIPELINESTATUS
!=
"success"
]
do
sleep
3
gitlab 200 GET /projects/
"
$PRJID
"
/pipelines/
"
$PIPELINEID
"
PIPELINESTATUS
=
$(
echo
"
$result
"
| jq
-r
.
"status"
)
echo
"
$PIPELINESTATUS
..."
case
"
${
PIPELINESTATUS
}
"
in
created
)
;;
pending
)
;;
running
)
;;
success
)
;;
*
)
exit
8
;;
esac
done
gitlab 200 GET /projects/
"
$PRJID
"
/pipelines/
"
$PIPELINEID
"
/jobs
JOBID
=
$(
echo
"
$result
"
| jq
-r
.[0].
"id"
)
gitlab 200 GET /projects/
"
$PRJID
"
/jobs/
"
$JOBID
"
/artifacts
--output
/tmp/artifacts.zip
echo
"Extract archive ..."
unzip
-o
/tmp/artifacts.zip
-d
/tmp
if
[[
"
$mode
"
==
"CollectDatabase"
]]
;
then
echo
"Copy DB dump into PHP container ..."
docker compose
cp
/tmp/drupal.sql php:/tmp
echo
"Import DB ..."
drush
-y
sql:drop
drush
-y
sql:query
--file
=
/tmp/drupal.sql
fi
if
[[
"
$mode
"
==
"CollectFiles"
]]
;
then
echo
"Please move the files from /tmp into your file directories manually."
fi
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