Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Bitbucket Plugin - Cannot parse POST data

Sending a POST request to /jenkins/bitbucket-hook causes a 500 error:

javax.servlet.ServletException: net.sf.json.JSONException: A JSONObject text must begin with '{' at character 0 of

Regardless of the content type, or body data. The body data being sent is that outlined by Bitbucket:

{
    "canon_url": "https://bitbucket.org",
    "commits": [
        {
            "author": "marcus",
            "branch": "master",
            "files": [
                {
                    "file": "somefile.py",
                    "type": "modified"
                }
            ],
            "message": "Added some more things to somefile.py\n",
            "node": "620ade18607a",
            "parents": [
                "702c70160afc"
            ],
            "raw_author": "Marcus Bertrand <[email protected]>",
            "raw_node": "620ade18607ac42d872b568bb92acaa9a28620e9",
            "revision": null,
            "size": -1,
            "timestamp": "2012-05-30 05:58:56",
            "utctimestamp": "2012-05-30 03:58:56+00:00"
        }
    ],
    "repository": {
        "absolute_url": "/marcus/project-x/",
        "fork": false,
        "is_private": true,
        "name": "Project X",
        "owner": "marcus",
        "scm": "git",
        "slug": "project-x",
        "website": "https://atlassian.com/"
    },
    "user": "marcus"
}

Jenkins is the most up to date version, along with the Bitbucket plugin.

Update: I have used the data directly taken from BitBucket. http://www.posttestserver.com/data/2015/05/20/sb/02.50.32555038623

like image 960
jshthornton Avatar asked May 11 '15 05:05

jshthornton


1 Answers

I think I have answered my own question.

For me to get rid of that error I just had to add a trailing slash to the url... Something so simple worked for me. Might be worth others trying it too.

like image 66
jshthornton Avatar answered Sep 28 '22 20:09

jshthornton