Closed infinity2357 closed 6 years ago
Hi @ArashAlikhani , I'm pretty sure that's possible! You just need get your hand on a payload dump in order to define the "mapped" structure. Please take a look at the current two Services: https://github.com/Webklex/laravel-git-hook/tree/master/src/GitHook/Payload/Services.
If you can't get it to work, please provide an example payload and let me know :)
Update: A good service class name would be GitlabService - if you are doing so you'll be able to use the new service by simply replacing 'github' or 'bitbucket' with 'gitlab' inside the config file.
Thanks @Webklex I fork the repo and try to figure out how should I define each parameter in $map for gitlab but I was not sure. All of Github values were null but Bitbucket values were strange! I didn't get it! Can u show me how should I define them properly? this is a gitlab payload dump (personal info replaced with Xs):
{
"object_kind":"push",
"event_name":"push",
"before":"5493d11aaae55061c238ac620c4a194a644accde",
"after":"81664a2cc11ce579ad1b385429c15f1b40343a1d",
"ref":"refs/heads/master",
"checkout_sha":"81664a2cc11ce579ad1b385429c15f1b40343a1d",
"message":null,
"user_id":XXXXXXX,
"user_name":"Arash",
"user_username":"XXX",
"user_email":"XXX@XXX.X",
"user_avatar":"XXX",
"project_id":XXXXXXX,
"project":{
"name":"laraveltest",
"description":"",
"web_url":"https://gitlab.com/XXXXXXXXX/laraveltest",
"avatar_url":null,
"git_ssh_url":"git@gitlab.com:XXXXXXXXX/laraveltest.git",
"git_http_url":"https://gitlab.com/XXXXXXXXX/laraveltest.git",
"namespace":"XXXXXXXXX",
"visibility_level":0,
"path_with_namespace":"XXXXXXXXX/laraveltest",
"default_branch":"master",
"ci_config_path":null,
"homepage":"https://gitlab.com/XXXXXXXXX/laraveltest",
"url":"git@gitlab.com:XXXXXXXXX/laraveltest.git",
"ssh_url":"git@gitlab.com:XXXXXXXXX/laraveltest.git",
"http_url":"https://gitlab.com/XXXXXXXXX/laraveltest.git"
},
"commits":[
{
"id":"81664a2cc11ce579ad1b385429c15f1b40343a1d",
"message":"add a test route to get gitlab webhook payload",
"timestamp":"2017-11-08T02:24:54+03:30",
"url":"https://gitlab.com/XXXXXXXXX/laraveltest/commit/81664a2cc11ce579ad1b385429c15f1b40343a1d",
"author":{
"name":"Arash",
"email":"XXX@XXX.X"
},
"added":[
],
"modified":[
"routes/api.php"
],
"removed":[
]
},
{
"id":"ae6e0e7df35b31ae26933959344e0fa8a7d18688",
"message":"add something (public/test.txt) to test if webhook works",
"timestamp":"2017-11-08T01:40:21+03:30",
"url":"https://gitlab.com/XXXXXXXXX/laraveltest/commit/ae6e0e7df35b31ae26933959344e0fa8a7d18688",
"author":{
"name":"Arash",
"email":"XXX@XXX.X"
},
"added":[
"public/test.txt"
],
"modified":[
],
"removed":[
]
},
{
"id":"5493d11aaae55061c238ac620c4a194a644accde",
"message":"set front-end preset to none and add laravel-git-hook and config its webhook url",
"timestamp":"2017-11-08T01:36:04+03:30",
"url":"https://gitlab.com/XXXXXXXXX/laraveltest/commit/5493d11aaae55061c238ac620c4a194a644accde",
"author":{
"name":"Arash",
"email":"XXX@XXX.X"
},
"added":[
"config/git-hook.php"
],
"modified":[
"composer.json",
"composer.lock",
"config/app.php",
"package.json",
"resources/assets/js/app.js",
"resources/assets/sass/app.scss"
],
"removed":[
"public/css/app.css",
"public/js/app.js",
"resources/assets/js/components/ExampleComponent.vue",
"resources/assets/sass/_variables.scss"
]
}
],
"total_commits_count":3,
"repository":{
"name":"laraveltest",
"url":"git@gitlab.com:XXXXXXXXX/laraveltest.git",
"description":"",
"homepage":"https://gitlab.com/XXXXXXXXX/laraveltest",
"git_http_url":"https://gitlab.com/XXXXXXXXX/laraveltest.git",
"git_ssh_url":"git@gitlab.com:XXXXXXXXX/laraveltest.git",
"visibility_level":0
}
}
and Thanks for the service name suggestion :)
I solved www-data ssh problem and it worked just fine with Github option :)
Update: if anybody wants to know how, checkout these: https://serverfault.com/questions/269359/allow-user-git-to-run-git-pull-as-www-data-via-sudo https://stackoverflow.com/questions/7306990/generating-ssh-keys-for-apache-user
New Update: I add GitlabService and update readme in my fork. Thanks a lot @Webklex
You are welcome :) Btw I just merged your changes into this repository.
can I use this for gitlab webhooks? (I can't see any option for it.) if not, can u show me how can I change it to adabt with gitlab? thanks :)