I just discovered that Bitbucket does not allow to choose specific
hook on pushing to any branch. It just calls all the hooks, then
starts all Jenkins jobs.
My solution was to create an specific file on my machine which Jenkins is installed and set a Bitbucket hook to this file. (e.g.
http://{jenkins url}:{apache port}/check.php)
Note that this apache port is not the same of Jenkins', but Apache's. In my case, Jenkins was running at 8080 and Apache at 7777.
It did this to run php script, but not in Jenkins' directory.
Since Bitbucket hook sends a json file, I was able to verify in check.php which branch has been pushed on. Reference: POST hook
management
After the verification using a simple 'if', I just called the right url to start the right job with exec_curl, like:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://{jenkins url}:{jenkins port}/job/{job name}/build?token={job token});
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
And voilà.