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
6686d8e3
Commit
6686d8e3
authored
2 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
gitlab-ci-cd/drupal#28
Make it work in pipelines too
parent
b9792bc5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Merging develop into main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/merge
+18
-12
18 additions, 12 deletions
bin/merge
with
18 additions
and
12 deletions
bin/merge
+
18
−
12
View file @
6686d8e3
...
...
@@ -45,24 +45,30 @@ function parseUrl() {
}
SOURCEBRANCH
=
$(
git rev-parse
--abbrev-ref
HEAD
)
if
[[
"
$SOURCEBRANCH
"
==
"main"
]]
;
then
echo
"Main branch can not be merged."
exit
1
elif
[[
"
$SOURCEBRANCH
"
==
"develop"
]]
;
then
TARGETBRANCH
=
main
else
TARGETBRANCH
=
develop
if
[[
"x
$TARGETBRANCH
"
==
"x"
]]
;
then
if
[[
"
$SOURCEBRANCH
"
==
"main"
]]
;
then
echo
"Main branch can not be merged."
exit
1
elif
[[
"
$SOURCEBRANCH
"
==
"develop"
]]
;
then
TARGETBRANCH
=
main
else
TARGETBRANCH
=
develop
fi
fi
if
[[
"
$TARGETBRANCH
"
==
"
$SOURCEBRANCH
"
]]
;
then
echo
"Source and target branches must be different."
exit
2
fi
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
2
exit
3
fi
if
[[
"x
${
GITLAB_PRIVATE_TOKEN
}
"
==
"x"
]]
;
then
echo
"Missing GITLAB_PRIVATE_TOKEN environment variable"
exit
3
exit
4
fi
parseUrl
"
$GITLAB_URL
"
host1
=
$host
...
...
@@ -70,7 +76,7 @@ parseUrl "$(git config remote.origin.url)"
host2
=
$host
if
[[
"
$host1
"
!=
"
$host2
"
]]
;
then
echo
"This repository doesn't match the provided GitLab instance"
exit
4
exit
5
fi
if
[[
-n
${
CI_PROJECT_ID
}
]]
;
then
...
...
@@ -83,7 +89,7 @@ else
PRJID
=
$(
echo
"
$result
"
| jq
-r
.[0].
"id"
)
if
[[
$(
isNumeric
"
$PRJID
"
)
-eq
1
]]
;
then
echo
"Can not find project ID"
exit
5
exit
6
fi
fi
...
...
@@ -93,7 +99,7 @@ gitlab 201 POST projects/"$PRJID"/merge_requests --data "source_branch=$SOURCEBR
MRID
=
$(
echo
"
$result
"
| jq
-r
.
"iid"
)
if
[[
$(
isNumeric
"
$MRID
"
)
-eq
1
]]
;
then
echo
"Can not create merge request"
exit
6
exit
7
fi
echo
"Created MR at
$(
echo
"
$result
"
| jq
-r
.
"web_url"
)
"
...
...
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