Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab-ci
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
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
SECO Northern Europe
Yocto
infrastructure
gitlab-ci
Commits
2aeb899a
Commit
2aeb899a
authored
2 years ago
by
Jonas Höppner
Browse files
Options
Downloads
Patches
Plain Diff
CI: merge_gitlab_ci: Fix some post merge issues
parent
7381d598
No related branches found
No related tags found
1 merge request
!113
CI: merge_gitlab_ci: Fix some post merge issues
Pipeline
#9069
failed with stage
Stage:
in 1 minute and 57 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
accept_merge_request.py
+2
-2
2 additions, 2 deletions
accept_merge_request.py
check_if_integration_branch_is_up_to_date.py
+9
-1
9 additions, 1 deletion
check_if_integration_branch_is_up_to_date.py
common.py
+1
-1
1 addition, 1 deletion
common.py
merge_gitlab_ci.py
+19
-1
19 additions, 1 deletion
merge_gitlab_ci.py
with
31 additions
and
5 deletions
accept_merge_request.py
+
2
−
2
View file @
2aeb899a
...
@@ -19,7 +19,7 @@ critical_error = (
...
@@ -19,7 +19,7 @@ critical_error = (
)
)
def
accept_merge_request
(
project
,
mr
,
rebase
=
False
):
def
accept_merge_request
(
project
,
mr
,
rebase
=
False
,
should_remove_source_branch
=
True
):
"""
Attempt to merge a merge request, rebase if necessary
"""
"""
Attempt to merge a merge request, rebase if necessary
"""
merged
=
False
merged
=
False
pipeline_pending
=
False
pipeline_pending
=
False
...
@@ -37,7 +37,7 @@ def accept_merge_request(project, mr, rebase=False):
...
@@ -37,7 +37,7 @@ def accept_merge_request(project, mr, rebase=False):
# Try to merge the merge request
# Try to merge the merge request
try
:
try
:
mr
.
merge
(
should_remove_source_branch
=
True
)
mr
.
merge
(
should_remove_source_branch
=
should_remove_source_branch
)
if
pipeline_pending
:
if
pipeline_pending
:
print
(
""
)
print
(
""
)
if
mr
.
state
==
"
merged
"
:
if
mr
.
state
==
"
merged
"
:
...
...
This diff is collapsed.
Click to expand it.
check_if_integration_branch_is_up_to_date.py
+
9
−
1
View file @
2aeb899a
...
@@ -15,12 +15,14 @@ def check_if_integration_branch_is_up_to_date(
...
@@ -15,12 +15,14 @@ def check_if_integration_branch_is_up_to_date(
):
):
integration_branch
=
None
integration_branch
=
None
branch_list
=
[]
if
merge_request
.
source_branch
.
startswith
(
"
integrate/gitlab-ci
"
):
if
merge_request
.
source_branch
.
startswith
(
"
integrate/gitlab-ci
"
):
try
:
try
:
integration_branch
=
manifest_project
.
branches
.
get
(
integration_branch
=
manifest_project
.
branches
.
get
(
merge_request
.
source_branch
,
merge_request
.
source_branch
,
retry_transient_errors
=
True
,
retry_transient_errors
=
True
,
)
)
branch_list
.
append
(
merge_request
.
source_branch
)
except
GitlabGetError
:
except
GitlabGetError
:
# Branch not found
# Branch not found
...
@@ -29,13 +31,19 @@ def check_if_integration_branch_is_up_to_date(
...
@@ -29,13 +31,19 @@ def check_if_integration_branch_is_up_to_date(
integration_branch_name
=
common
.
integration_branch_name
(
integration_branch_name
=
common
.
integration_branch_name
(
project
.
name
,
merge_request
.
source_branch
project
.
name
,
merge_request
.
source_branch
)
)
branch_list
.
append
(
integration_branch
)
try
:
try
:
integration_branch
=
manifest_project
.
branches
.
get
(
integration_branch
=
manifest_project
.
branches
.
get
(
integration_branch_name
,
integration_branch_name
,
retry_transient_errors
=
True
,
retry_transient_errors
=
True
,
)
)
except
GitlabGetError
:
except
GitlabGetError
:
sys
.
exit
(
"
ERROR: could not find integration branch
\n
"
)
sys
.
exit
(
"
ERROR: could not find integration branch in %s,
"
"
branch names checked: %s
\n
"
,
manifest_project
.
name
,
branch_list
,
)
try
:
try
:
integration_base_branch
=
manifest_project
.
branches
.
get
(
integration_base_branch
=
manifest_project
.
branches
.
get
(
...
...
This diff is collapsed.
Click to expand it.
common.py
+
1
−
1
View file @
2aeb899a
...
@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit)
...
@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit)
)
from
e
)
from
e
# The integration branch is up to date if its parent is the integration base
# The integration branch is up to date if its parent is the integration base
logging
.
debug
(
"
Compare
'
%s
'
and
'
%s
'"
,
parent
.
id
,
commit
)
logging
.
debug
(
"
Compare
'
%s
'
and
'
%s
'"
,
parent
.
id
,
commit
)
if
parent
.
id
==
commit
:
if
parent
.
id
==
commit
:
return
True
return
True
if
len
(
parent
.
parent_ids
)
==
0
:
if
len
(
parent
.
parent_ids
)
==
0
:
...
...
This diff is collapsed.
Click to expand it.
merge_gitlab_ci.py
+
19
−
1
View file @
2aeb899a
...
@@ -156,6 +156,11 @@ def main():
...
@@ -156,6 +156,11 @@ def main():
# deploy_gitlab_ci again to create a new integration
# deploy_gitlab_ci again to create a new integration
# commit or make sure the change is already integrated.
# commit or make sure the change is already integrated.
# Store for later usage:
if
p
==
args
.
project
:
manifest_project
=
project
manifest_integration_mr
=
mr
print
(
"
Merge {}!{}: {}
"
.
format
(
project
.
name
,
mr
.
iid
,
mr
.
title
))
print
(
"
Merge {}!{}: {}
"
.
format
(
project
.
name
,
mr
.
iid
,
mr
.
title
))
# Wait until GitLab has checked merge status
# Wait until GitLab has checked merge status
common
.
wait_until_merge_status_is_set
(
project
,
mr
)
common
.
wait_until_merge_status_is_set
(
project
,
mr
)
...
@@ -167,6 +172,10 @@ def main():
...
@@ -167,6 +172,10 @@ def main():
# Only the file manifest commit may be rebased
# Only the file manifest commit may be rebased
# other rebase would require new integration commits
# other rebase would require new integration commits
rebase
=
(
p
==
args
.
project
),
rebase
=
(
p
==
args
.
project
),
# For the manifest we keep the source branch
# otherwise does the check job fail for not yet merged
# child projects
should_remove_source_branch
=
(
p
==
args
.
project
),
)
)
if
not
merged
:
if
not
merged
:
...
@@ -185,9 +194,18 @@ def main():
...
@@ -185,9 +194,18 @@ def main():
continue
continue
if
not
found
:
if
not
found
:
continue
continue
print
(
"
{}
"
.
format
(
p2
.
name
))
print
(
"
{}
"
.
format
(
p2
))
sys
.
exit
()
sys
.
exit
()
# Delete args.project (manifests) integration branch
# (skipped the deletion during the merge request merge before)
integration_branch
=
manifest_project
.
branches
.
get
(
manifest_integration_mr
.
source_branch
)
manifest_project
.
branches
.
delete
(
integration_branch
.
get_id
(),
retry_transient_errors
=
True
)
print
(
"
Successfully merged
"
)
print
(
"
Successfully merged
"
)
exit
()
exit
()
...
...
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