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
c16ae4ea
Commit
c16ae4ea
authored
3 years ago
by
Tim Jaacks
Browse files
Options
Downloads
Patches
Plain Diff
check_pipeline_status: add parameter for trigger source
parent
d321e1f6
No related branches found
Branches containing commit
No related tags found
1 merge request
!66
check_pipeline_status: add parameter for trigger source
Pipeline
#8481
passed with stages
Stage:
Stage:
in 4 minutes and 1 second
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_pipeline_status.py
+13
-3
13 additions, 3 deletions
check_pipeline_status.py
with
13 additions
and
3 deletions
check_pipeline_status.py
+
13
−
3
View file @
c16ae4ea
...
...
@@ -9,11 +9,13 @@ from gitlab import Gitlab, GitlabGetError
from
gitlab.v4.objects
import
Project
def
check_pipeline_status
(
project
:
Project
,
commit
):
def
check_pipeline_status
(
project
:
Project
,
commit
,
source
):
"""
Get latest pipeline status for a given commit
"""
# Find pipeline for commit
pipelines
=
project
.
pipelines
.
list
(
sha
=
commit
,
retry_transient_errors
=
True
)
pipelines
=
project
.
pipelines
.
list
(
sha
=
commit
,
source
=
source
,
retry_transient_errors
=
True
)
if
not
pipelines
:
print
(
"
ERROR: no pipeline for commit
'
%s
'
found
"
%
commit
)
sys
.
exit
(
1
)
...
...
@@ -58,13 +60,21 @@ def main():
dest
=
"
commit
"
,
required
=
True
,
)
parser
.
add_argument
(
"
--source
"
,
help
=
"""
source that triggered the pipeline
"""
,
choices
=
[
"
push
"
,
"
merge_request_event
"
],
dest
=
"
source
"
,
default
=
"
push
"
,
required
=
False
,
)
args
,
_
=
parser
.
parse_known_args
()
gitlab
=
Gitlab
(
args
.
gitlab_url
,
private_token
=
args
.
token
)
project
=
common
.
get_project
(
gitlab
,
args
.
project
)
status
=
check_pipeline_status
(
project
,
args
.
commit
)
status
=
check_pipeline_status
(
project
,
args
.
commit
,
args
.
source
)
# If we are running in a job environment and the upstream status is canceled,
# explicitly cancel this job as well
...
...
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