PreReceiveHook and PostReceiveHook are not invoked

その他

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

When using the Atlassian SDK to run Stash 2.0.x on Mac or Linux, the onReceive() method on a PreReceiveHook or PostReceiveHook is not triggered when pushing to the default repository (PROJECT_1 / rep_1). Branch permissions (which are implemented as PreReceiveHooks) will also not work for rep_1.

原因

The hook scripts in the rep_1 repository in the default stash-plugin-test-resources.zip setup by AMPS doesn't have the executable permissions set. git-receive-pack ignores non-executable scripts, so no hooks are invoked when you push to rep_1.

解決状況

(The quick way) Create a new repository

Any new repositories will have their hook scripts correctly initialised, so the easiest way to workaround this issue is simply to create a new repository for testing your plugin. 

That's it! Hooks should now work correctly for the newly created repository.

(The slightly longer way) Manually set the script permissions

  1. From your plugin directory, navigate to /target/stash/home/data/repositories/1/hooks
  2. Run ls -l * 
  3. You should see the following output:

    tpettersen@hoprocker ~/example-plugin/target/stash/home/data/repositories/1/hooks (BARE:master) $ ls -l -r *
    -rw-r--r--  1 tpettersen  staff  3611 20 Dec 00:35 update.sample
    -rw-r--r--  1 tpettersen  staff  1239 20 Dec 00:35 prepare-commit-msg.sample
    -rw-r--r--  1 tpettersen  staff   424 20 Dec 00:35 pre-receive
    -rw-r--r--  1 tpettersen  staff  4951 20 Dec 00:35 pre-rebase.sample
    -rw-r--r--  1 tpettersen  staff  1704 20 Dec 00:35 pre-commit.sample
    -rw-r--r--  1 tpettersen  staff   398 20 Dec 00:35 pre-applypatch.sample
    -rw-r--r--  1 tpettersen  staff   189 20 Dec 00:35 post-update.sample
    -rw-r--r--  1 tpettersen  staff   426 20 Dec 00:35 post-receive
    -rw-r--r--  1 tpettersen  staff   896 20 Dec 00:35 commit-msg.sample
    -rw-r--r--  1 tpettersen  staff   452 20 Dec 00:35 applypatch-msg.sample
    pre-receive.d:
    total 8
    -rw-r--r--  1 tpettersen  staff  410 20 Dec 00:35 20_stash_callback
    post-receive.d:
    total 8
    -rw-r--r--  1 tpettersen  staff  412 20 Dec 00:35 20_stash_callback
  4. Run chmod -R a+x *
  5. Run ls -l * again
  6. You should see the following output (note the scripts are now executable):

    tpettersen@hoprocker ~/example-plugin/target/stash/home/data/repositories/1/hooks (BARE:master) $ chmod -R a+x *
    tpettersen@hoprocker ~/example-plugin/target/stash/home/data/repositories/1/hooks (BARE:master) $ ls -l *
    -rwxr-xr-x  1 tpettersen  staff   452 20 Dec 00:35 applypatch-msg.sample
    -rwxr-xr-x  1 tpettersen  staff   896 20 Dec 00:35 commit-msg.sample
    -rwxr-xr-x  1 tpettersen  staff   426 20 Dec 00:35 post-receive
    -rwxr-xr-x  1 tpettersen  staff   189 20 Dec 00:35 post-update.sample
    -rwxr-xr-x  1 tpettersen  staff   398 20 Dec 00:35 pre-applypatch.sample
    -rwxr-xr-x  1 tpettersen  staff  1704 20 Dec 00:35 pre-commit.sample
    -rwxr-xr-x  1 tpettersen  staff  4951 20 Dec 00:35 pre-rebase.sample
    -rwxr-xr-x  1 tpettersen  staff   424 20 Dec 00:35 pre-receive
    -rwxr-xr-x  1 tpettersen  staff  1239 20 Dec 00:35 prepare-commit-msg.sample
    -rwxr-xr-x  1 tpettersen  staff  3611 20 Dec 00:35 update.sample
    post-receive.d:
    total 8
    -rwxr-xr-x  1 tpettersen  staff  412 20 Dec 00:35 20_stash_callback
    pre-receive.d:
    total 8
    -rwxr-xr-x  1 tpettersen  staff  410 20 Dec 00:35 20_stash_callback
  7. Your commit hooks will be triggered on the next push to rep_1.
最終更新日: 2012 年 12 月 21 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.