Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-deps
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Show more breadcrumbs
pipelines
tools
gitlab-deps
Commits
3ed99637
Commit
3ed99637
authored
4 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add a "set-hooks" command to set pipeline hooks on projects
parent
ec4523cd
No related branches found
No related tags found
1 merge request
!1
Modular
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gitlab_docker_autodep/hooks.py
+16
-0
16 additions, 0 deletions
gitlab_docker_autodep/hooks.py
gitlab_docker_autodep/main.py
+24
-1
24 additions, 1 deletion
gitlab_docker_autodep/main.py
with
40 additions
and
1 deletion
gitlab_docker_autodep/hooks.py
0 → 100644
+
16
−
0
View file @
3ed99637
def
check_hook
(
gl
,
hook_url
,
webhook_token
,
project_path
):
project
=
gl
.
projects
.
get
(
project_path
)
found
=
False
for
h
in
project
.
hooks
.
list
():
if
h
.
url
==
hook_url
and
h
.
pipeline_events
:
found
=
True
break
if
found
:
return
project
.
hooks
.
add
(
url
=
hook_url
,
pipeline_events
=
True
,
token
=
webhook_token
,
)
This diff is collapsed.
Click to expand it.
gitlab_docker_autodep/main.py
+
24
−
1
View file @
3ed99637
...
@@ -7,6 +7,7 @@ import urllib.parse as urlparse
...
@@ -7,6 +7,7 @@ import urllib.parse as urlparse
from
.deps
import
get_branches
,
list_projects
,
list_deps
,
\
from
.deps
import
get_branches
,
list_projects
,
list_deps
,
\
split_project_branch
,
read_deps
split_project_branch
,
read_deps
from
.hooks
import
check_hook
from
.rebuild
import
rebuild_deps
from
.rebuild
import
rebuild_deps
from
.server
import
run_app
from
.server
import
run_app
...
@@ -63,6 +64,20 @@ def main():
...
@@ -63,6 +64,20 @@ def main():
'
--docker
'
,
action
=
'
store_true
'
,
'
--docker
'
,
action
=
'
store_true
'
,
help
=
'
Output dependencies between Docker images, not Gitlab projects
'
)
help
=
'
Output dependencies between Docker images, not Gitlab projects
'
)
# Setup pipeline hooks on the specified projects.
set_hooks_parser
=
subparsers
.
add_parser
(
'
set-hooks
'
,
parents
=
[
common_parser
],
help
=
'
set pipeline hooks on projects
'
,
description
=
'
Set the pipeline hooks on the specified projects
'
'
(usually points at our own server)
'
)
set_hooks_parser
.
add_argument
(
'
--hook-url
'
,
metavar
=
'
URL
'
,
help
=
'
URL for the pipeline HTTP hook
'
)
set_hooks_parser
.
add_argument
(
'
--webhook-auth-token
'
,
metavar
=
'
TOKEN
'
,
help
=
'
Secret X-Gitlab-Token for request authentication
'
)
# Trigger rebuilds of reverse deps.
# Trigger rebuilds of reverse deps.
rebuild_image_parser
=
subparsers
.
add_parser
(
rebuild_image_parser
=
subparsers
.
add_parser
(
'
rebuild
'
,
'
rebuild
'
,
...
@@ -140,9 +155,17 @@ def main():
...
@@ -140,9 +155,17 @@ def main():
project_path
,
branch_name
=
split_project_branch
(
args
.
project_path
)
project_path
,
branch_name
=
split_project_branch
(
args
.
project_path
)
rebuild_deps
(
gl
,
deps
,
project_path
,
branch_name
,
args
.
dry_run
,
rebuild_deps
(
gl
,
deps
,
project_path
,
branch_name
,
args
.
dry_run
,
args
.
recurse
)
args
.
recurse
)
elif
cmd
==
'
set-hooks
'
:
if
not
args
.
hook_url
:
parser
.
error
(
'
Must specify --hook-url
'
)
# Need a project list on input, ignore branches.
projects
=
set
(
y
[
0
]
for
y
in
(
split_project_branch
(
x
.
strip
())
for
x
in
sys
.
stdin
))
for
project_path
in
projects
:
check_hook
(
gl
,
args
.
hook_url
,
args
.
webhook_auth_token
,
project_path
)
elif
cmd
==
'
server
'
:
elif
cmd
==
'
server
'
:
deps
=
read_deps
(
sys
.
stdin
)
deps
=
read_deps
(
sys
.
stdin
)
# TODO
run_app
(
gl
,
deps
,
args
.
bind_host
,
args
.
bind_port
,
run_app
(
gl
,
deps
,
args
.
bind_host
,
args
.
bind_port
,
args
.
webhook_auth_token
)
args
.
webhook_auth_token
)
...
...
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