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
55b9004e
Commit
55b9004e
authored
7 years ago
by
Pavel KORSHUNOV
Browse files
Options
Downloads
Patches
Plain Diff
cancel duplicated pipelines, wait before quering pipelines
parent
6fe3e6f1
No related branches found
No related tags found
1 merge request
!75
The release script for bob that uses changelog as a guidance for release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
release/release_bob.py
+27
-11
27 additions, 11 deletions
release/release_bob.py
with
27 additions
and
11 deletions
release/release_bob.py
+
27
−
11
View file @
55b9004e
...
...
@@ -135,21 +135,33 @@ def commit_files(gitpkg, files_list, message='Updated files', dry_run=False):
gitpkg
.
commits
.
create
(
data
)
def
get_last_nonskip_pipeline
(
gitpkg
,
before_last
=
False
):
# sleep for 10 seconds to ensure that if a pipeline was just submitted,
# we can retrieve it
time
.
sleep
(
10
)
if
before_last
:
# take the pipeline before the last
return
gitpkg
.
pipelines
.
list
(
per_page
=
2
,
page
=
1
)[
1
]
else
:
# otherwise take the last pipeline
return
gitpkg
.
pipelines
.
list
(
per_page
=
1
,
page
=
1
)[
0
]
def
just_build_package
(
gitpkg
,
dry_run
=
False
):
# we assume the last pipeline is with commit [skip ci]
# so, we take the pipeline that can be re-built, which the previous to the last one
last_pipeline
=
g
itpkg
.
pipelines
.
list
(
per_page
=
2
,
page
=
1
)[
1
]
last_pipeline
=
g
et_last_nonskip_pipeline
(
gitpkg
,
before_last
=
True
)
# check that the chosen pipeline is the one we are looking for
latest_tag_name
=
gitpkg
.
tags
.
list
(
per_page
=
1
,
page
=
1
)[
0
].
name
# the pipeline should be the one built for the latest tag, so check if it is the correct choice
if
last_pipeline
.
ref
!=
latest_tag_name
:
raise
ValueError
(
'
While deploying
package
, found pipeline {
0
} but it does not match
'
'
the latest tag {
1
}
'
.
format
(
last_pipeline
.
id
,
latest_tag_name
))
raise
ValueError
(
'
While deploying
{0}
, found pipeline {
1
} but it does not match
'
'
the latest tag {
2
}
'
.
format
(
gitpkg
.
name
,
last_pipeline
.
id
,
latest_tag_name
))
# the pipeline should have succeeded, otherwise we cannot release
if
last_pipeline
.
status
!=
'
success
'
:
raise
ValueError
(
'
While deploying
package
, found pipeline {
0
} but its status
'
'
is
"
{1}
"
instead
of the expected
"
sucess
"'
.
format
(
last_pipeline
.
id
,
last_pipeline
.
status
))
raise
ValueError
(
'
While deploying
{0}
, found pipeline {
1
} but its status
is
"
{2}
"
instead
'
'
of the expected
"
sucess
"'
.
format
(
gitpkg
.
name
,
last_pipeline
.
id
,
last_pipeline
.
status
))
print
(
"
Retrying pipeline {0}
"
.
format
(
last_pipeline
.
id
))
if
not
dry_run
:
...
...
@@ -159,12 +171,7 @@ def just_build_package(gitpkg, dry_run=False):
def
wait_for_pipeline_to_finish
(
gitpkg
,
tag
,
dry_run
=
False
):
sleep_step
=
30
max_sleep
=
60
*
60
# one hour
if
tag
==
'
none
'
:
# take the pipeline before the last
pipeline
=
gitpkg
.
pipelines
.
list
(
per_page
=
2
,
page
=
1
)[
1
]
else
:
# otherwise just take the last pipeline
pipeline
=
gitpkg
.
pipelines
.
list
(
per_page
=
1
,
page
=
1
)[
0
]
pipeline
=
get_last_nonskip_pipeline
(
gitpkg
,
before_last
=
True
)
pipeline_id
=
pipeline
.
id
...
...
@@ -192,6 +199,12 @@ def wait_for_pipeline_to_finish(gitpkg, tag, dry_run=False):
print
(
'
Pipeline {0} of package {1} succeeded. Continue processing.
'
.
format
(
pipeline_id
,
gitpkg
.
name
))
def
cancel_last_pipeline
(
gitpkg
):
pipeline
=
get_last_nonskip_pipeline
(
gitpkg
)
print
(
'
Cancelling the last pipeline {0} of project {1}
'
.
format
(
pipeline
.
id
,
gitpkg
.
name
))
pipeline
.
cancel
()
def
release_package
(
gitpkg
,
tag_name
,
tag_comments_list
,
dry_run
=
False
):
# if there is nothing to release, just rebuild the package
if
tag_name
==
'
none
'
:
...
...
@@ -206,6 +219,9 @@ def release_package(gitpkg, tag_name, tag_comments_list, dry_run=False):
# commit and push changes
commit_files
(
gitpkg
,
{
'
README.rst
'
:
readme_content
,
'
version.txt
'
:
version_number
},
'
Increased stable version to %s
'
%
version_number
,
dry_run
)
if
not
dry_run
:
# cancel running the pipeline triggered by the last commit
cancel_last_pipeline
(
gitpkg
)
# 2. Tag package with new tag and push
print
(
"
Creating tag {}
"
.
format
(
tag_name
))
...
...
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