Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
silver-platter
gitlab-deps
Commits
3ed99637
Commit
3ed99637
authored
Jul 01, 2020
by
ale
Browse files
Add a "set-hooks" command to set pipeline hooks on projects
parent
ec4523cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
gitlab_docker_autodep/hooks.py
0 → 100644
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
,
)
gitlab_docker_autodep/main.py
View file @
3ed99637
...
...
@@ -7,6 +7,7 @@ import urllib.parse as urlparse
from
.deps
import
get_branches
,
list_projects
,
list_deps
,
\
split_project_branch
,
read_deps
from
.hooks
import
check_hook
from
.rebuild
import
rebuild_deps
from
.server
import
run_app
...
...
@@ -63,6 +64,20 @@ def main():
'--docker'
,
action
=
'store_true'
,
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.
rebuild_image_parser
=
subparsers
.
add_parser
(
'rebuild'
,
...
...
@@ -140,9 +155,17 @@ def main():
project_path
,
branch_name
=
split_project_branch
(
args
.
project_path
)
rebuild_deps
(
gl
,
deps
,
project_path
,
branch_name
,
args
.
dry_run
,
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'
:
deps
=
read_deps
(
sys
.
stdin
)
# TODO
run_app
(
gl
,
deps
,
args
.
bind_host
,
args
.
bind_port
,
args
.
webhook_auth_token
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment