Hook response in client console/git

Hi All,

I'm not able to see the output in my git console after doing

git push http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.git

I did SDK setup and run it properly.

I got stash console and I able to see the commited messages there.

I enabled the hook in my project repo settings

Everything is working fine but want to see the output after pushing,

Added this print statement at start line in my hook class of public boolean onReceive()

hookResponse.out().println("=============================================== check check check ==========================================");

So can anyone suggest how to get that print statement in client console/git

or where can i find the print statements.

Thanks in advance

Anil

5 answers

1 accepted

0 votes
Accepted answer

Hi All,

I figured out the problem, i.e., Earlier after installing the atlas sdk nd created plugin and in te hook file i put some print statements and i expected output in client console i.e., on git after doing git push ..

The solution i observed is i need to re run the "atlas-run"

@Balazs Szakmary, thanks for the suggestions.

@Michael Heemskerk, thanks for the debug tip. For now i am not using the ide tool to debug due to other task, but i need to do the debug in eclipse etc.,.I'l come here for the ide issue(s) etc.,

Thanks&Regards

Anil Kumar

Ah yes, you definitely need to redeploy your plugin when you make a change. You don't have to restart your whole server though. As an alternative you can run atlas-cli (in the directory containing the pom.xml of your plugin) and then pi to reinstall the plugin

Hi Michael,

Thanks for the plugin reinstallation tip,

I need to get and show the merge details of plugin, actually just I created a new question.

https://answers.atlassian.com/questions/272326/how-to-get-the-merge-details-with-plugin

Can you suggest the way on this.

Regards

Anil

Hi,

If you are rejecting the commit, you should print the reason like this:

hookResponse.err().println(errorMessage);

and then it will get to the client.

Hope this helps,

Balazs

Hi Balazs,

I tried with hookResponse.err().println(" some text"), inorder to display something in client console.

But it is not happening.

My doubt is My hoook class is not at all executing and after doing git push "http://xxxxx.git"

To check I used in my hook class like this

public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)

{

return false

}

after this I dded and commited some files and now with git push "http://xxxxx.git" it is simply pushing the contents to the git.

I think my hook is not at all calling...how to check whether my hook class is getting call/working properly..

Regards

Anil

Hi Balazs,

I tried with hookResponse.err().println(" some text"), inorder to display something in client console.

But it is not happening.

My doubt is My hoook class is not at all executing and after doing git push "http://xxxxx.git"

To check I used in my hook class like this

public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)

{

return false

}

after this I dded and commited some files and now with git push "http://xxxxx.git" it is simply pushing the contents to the git.

I think my hook is not at all calling...how to check whether my hook class is getting call/working properly..

Regards

Anil

Hi,

Is the hook enabled for the repository where you are pushing? You need to do this one-by-one for all the repos where you want to do this. (Settings/hooks on the web interface.)

Balazs

Yes, Balazs Szakmary, I already enabled it. And then I'm trying. I didnt get why my print staements are not displaying in git and even I just did return false in public boolean onReceive(){} though push is working with git, But it should not be.

I missed something else. but main thing is why my hook class is not getting called?..

All the commits which I did in git were displayed in stash server.

Can you suggest me why my hook class is not calling.

Just I uploaded the snaps of Repo permission, Hook Settings, Project permissions.

Is there any wrong in it/Did I miss anything...

Anil

Hi,

Sorry, I am out of ideas. If it is installed correctly and enabled on the repo you are pushing to, the return false should reject the push.

0 votes

Hi,

As a first test to verify that your hook is being called, I'd spin up Stash in debug mode and set a breakpoint in your onReceive method (or alternatively, write something to the Stash log).

Cheers,

Michael

Hi Michael,

Thanks for the reply. May I know how to do "Stash in debug mode" and setting the breakpoint.

Actually, I configured the SDK and I'm running the plugin. But I didn't integrate into Eclipose IDE.

I think as per you inorder to debug , I need to work with IDE right?..or normally without IDE also can we debug?..

Reards

Anil

you can start up Stash in debug mode by using atlas-debug. Then you need to set up a remote debug target in Eclipse to attach the debugger.

https://developer.atlassian.com/display/DOCS/Creating+a+Remote+Debug+Target

should provide some guidance

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

426 views 6 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you