Page MenuHomePhabricator

Phabricator api not getting called from SVN pre-commit hook
Open, WishlistPublic

Description

Hello,

I want to call a phabricator api from my SVN pre-commit hook.
Pre-commit hook is getting executed but API is not getting called at all.
I tried with Git, and it's working fine.

Here is a sample pre-commit hook script :

#!/bin/sh

echo "Hello..." >> /tmp/pre_commit.txt

echo '{"status":"status-accepted", "ids":[27]}' | arc --conduit-uri="http://phab-ip-address/" call-conduit differential.query >> /tmp/pre_commit.txt

echo "RESULT : " $RESULT >> /tmp/pre_commit.txt

If anyone knows the answer, please reply.

Thanks.

Event Timeline

taher raised the priority of this task from to High.
taher updated the task description. (Show Details)
taher added a subscriber: taher.

SVN wipes the environment, so my guess is that arc is no longer in PATH. You could try redirecting stderr as well to see the issue:

... | arc ... 2>&1 >> /tmp/pre_commit.tmp

If I'm right, that will probably show you something like:

-bash: arc: command not found

...and the fix will be to define PATH in your script before calling arc, or use an absolute path to arc.

Thanks for the reply epriestley.
Now I have given absolute path of arc in shell script.
Everytime I am getting following error.
"
Usage Exception: YOU NEED TO AUTHENTICATE TO CONTINUE

You are trying to connect to a server (10.74.75.158) that you do not have any credentials stored for.

To retrieve and store credentials for this server, run this command:

$ arc --conduit-uri='http://10.74.75.158/api/' install-certificate

"

I ran this command and installed the certificate successfully.
But, still I am getting same error message when pre-commit hook gets executed.

Thanks.

The HOME environmental variable is also getting wiped out, so we don't know where to find ~/.arcrc, which contains the credentials you installed.

epriestley claimed this task.

Presuming this is resolved.

Hello epriestley.
Thanks for the reply.

Now, I have exported the .arcrc file path in shell script. Still I am getting the same error.
Here is my updated shell script.
"
#!/bin/sh

export PATH="$PATH:/home/user/.arcrc"

echo "Hello..." >> /tmp/pre_commit.txt

echo '{"status":"status-accepted", "ids":[27]}' | /home/user/arcanist/arcanist/bin/arc --conduit-uri="http://phab-ip-address/" call-conduit differential.query >> /tmp/pre_commit.txt

"

The content of ".arcrc" file is :

{

"hosts": {
  "http:\/\/10.74.75.158\/api\/": {
    "token": "MY-API-TOKEN"
  }
}

}

Am I missing something here?
Please help me.

Thanks.

I have two other user accounts(not Admin account) created in my Phabricator.
Do I need to add those user's API token into .arcrc file?
If yes. How should I achieve this?

Thanks.

Does anyone know the answer?
Please reply.

--Thanks.

epriestley lowered the priority of this task from High to Wishlist.