Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tools.gitlab_webhook_receiver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
osp
tools.gitlab_webhook_receiver
Commits
9bc17884
Commit
9bc17884
authored
Jul 18, 2016
by
alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic primitive version
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
.gitignore
.gitignore
+1
-0
app.py
app.py
+32
-0
No files found.
.gitignore
0 → 100644
View file @
9bc17884
venv
app.py
0 → 100644
View file @
9bc17884
import
os
import
shlex
import
subprocess
import
json
from
bottle
import
request
,
route
,
run
@
route
(
'/'
,
method
=
'POST'
)
def
index
():
print
(
"received request"
)
if
request
.
headers
.
get
(
'X-Gitlab-Event'
)
==
'Push Hook'
:
# print("push hook")
data
=
json
.
load
(
request
.
body
)
repo
=
data
.
get
(
"repository"
)
git_http_url
=
repo
.
get
(
"git_ssh_url"
)
repo_name
=
git_http_url
.
split
(
"/"
)[
-
1
]
repo_local_path
=
os
.
path
.
join
(
"/tmp"
,
repo_name
)
if
os
.
path
.
isdir
(
repo_local_path
):
# print("repo exists. Pulling")
cmd
=
"git fetch origin master:master"
subprocess
.
Popen
(
shlex
.
split
(
cmd
),
cwd
=
repo_local_path
)
else
:
# print("repo don't exist. Cloning")
cmd
=
"git clone --bare %s"
%
git_http_url
subprocess
.
Popen
(
shlex
.
split
(
cmd
),
cwd
=
"/tmp"
)
run
(
host
=
'localhost'
,
port
=
8080
)
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