Skip to content

Commit

Permalink
Readme Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanchai committed Oct 7, 2015
1 parent de93a04 commit 58809f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INSTALLATION

- Edit the config file and rename it to 'config.php'
- Copy the deploy folder on your FTP server
- On Bitbucket>Admin>Hooks, setup a POST hook pointing to http://myserver/deploy/deploy.php
- On Bitbucket>Settings>Services, setup a POST hook pointing to http://myserver/deploy/deploy.php

**/!\** If you want to use Webhooks, you need a SSL certificate **/!\** (not tested)

Expand Down

10 comments on commit 58809f4

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Oct 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They say that you need a SSL certificate when using the HTTPS protocol - so I don't think that a certificate is needed if using HTTP. :)
I haven't tried this script against the webhook interface yet, mind you.
Bitbucket is deprecating the post hook, so it will need to work against webhook.

https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html

@Wanchai
Copy link
Owner Author

@Wanchai Wanchai commented on 58809f4 Nov 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is 2 kind of hooks :

  • the POST service, with http (deprecated)
  • the Webhook, with https which requires a SSL certificate. (not tested)

I hope it's more clear ;)

I hope BB will still offer a non-secured server hook option ...

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Nov 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to tell you that the webhook indeed works with regular http.
I tested it and got a response (payload).
The problem is just that BB is not sending a POST at all, it is a json 'payload'.

I found this: http://pastebin.com/WAuipRYh#

If you put this into it:

    $raw_json = $inputJSON;
    /* store original json */
    file_put_contents('bitbucketwebhook.json', $raw_json);

Then you can use a json viewer to figure out where to find things.

Here is an example payload as received from the linked to script: http://pastebin.com/mbXVT9uV

Hope that helps :)

I will hopefully return with a solution.

@Wanchai
Copy link
Owner Author

@Wanchai Wanchai commented on 58809f4 Nov 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HA!
Ok, didn't know that. I'm testing it and it seems to work.

The JSON payload seems easy to parse.

I'm working on it and gonna push it later tonight.

@Wanchai
Copy link
Owner Author

@Wanchai Wanchai commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ... the file list is not available from webhooks

https://bitbucket.org/site/master/issues/11703/add-modified-file-list-in-the-repo-push

Too bad 😞

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know.
However, that is relatively easy enough - in theory - to deal with.
If you look at the payload it will tell you the hash of the commits and then you can ask BB for that commit and get the list of files that changed.
After that, just download them directly from the repository, using the hash (commit id).
If you use http://restbrowser.bitbucket.org/ you can test it before coding it. :)

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.
In the payload, you need to find push-changes-commits-hash
And then you call the api
https://bitbucket.org/api/1.0/repositories/jacmoe/webhooktest/changesets/HASH/
That will give you a json response like this:

{
  "node": "3138828e2fef",
  "files": [
    {
      "type": "modified",
      "file": "test.txt"
    }
  ],
  "raw_author": "jacmoe <[email protected]>",
  "utctimestamp": "2015-10-31 10:07:01+00:00",
  "author": "jacmoe",
  "timestamp": "2015-10-31 11:07:01",
  "raw_node": "3138828e2feff32376cab42750f90143220ff1c4",
  "parents": [
    "776bfaebd09b"
  ],
  "branch": "default",
  "message": "debugging",

Then you can fetch them from the repository. Hopefully.

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is then at:
https://bitbucket.org/jacmoe/webhooktest/raw/3138828e2feff32376cab42750f90143220ff1c4/test.txt

I haven't had the time to test any of this :)

@jacmoe
Copy link

@jacmoe jacmoe commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for good measure:
payload1

@Wanchai
Copy link
Owner Author

@Wanchai Wanchai commented on 58809f4 Nov 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a huge help.
I'll check that later and implement it. Thanks!

Please sign in to comment.