1

When I commit my code form source tree bitbucket triggers a webhook that hit php code

exec('cd /d ' . $web_root_dir . ' && '. $git_bin_path  . ' pull origin master'); 

it won't execute but when I copy the same command by copying from the log on command prompt it execute perfectly.

I've tried my heart out on this but no result.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Git doesn't execute bitbucket-webhooks; only bitbucket does that. I snipped the [tag:git] tag, but I suspect this isn't a php issue either, just a bitbucket one... – torek Aug 10 '21 at 19:35
  • @torek No, webhook triggers the path that is provided to push webhook but once that triggers the file then these mentioned commands doesn't execute and same command when I copy form log that is created against that file is working absolutely fine. – Ali Abdullah Aug 11 '21 at 05:23
  • I am not sure what a "form log" might be (is this a typo, "copy *from* log"?) but running a command locally, on your computer, is very different from having Bitbucket run a command on *their* computer, because they have to be careful that you don't run *arbitrary* commands that could alter someone else's repository, for instance. I'd also note that `cd /d/foo` is probably the *wrong path* on bitbucket as the repository is probably not under a `/d` top level directory. **All of these are bitbucket-related issues.** – torek Aug 11 '21 at 18:03
  • @torek I've changed the command a bit **cd /d d:\directorytogit && git pull origin master** But still it's not giving me the response when webhook call this link and the same command that hook is calling I'm making the log and I copy the command from the log and run in CMD and it's working perfectly fine. – Ali Abdullah Aug 16 '21 at 11:13
  • Given that Bitbucket hosts are likely running Linux, `d:` is never going to be right. It looks like they expand a text literal `BITBUCKET_HOME`, based on [this page](https://confluence.atlassian.com/bitbucketserverkb/how-to-create-a-simple-hook-in-bitbucket-server-779171711.html). – torek Aug 16 '21 at 11:27
  • @torek I've ticked a bit in this instead of calling webhook. I created Task scheduler to run git commands and it's working perfectly :) – Ali Abdullah Aug 24 '21 at 12:12

0 Answers0