Community moderators have prevented the ability to post new answers.
Hi,
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
Ok, I was misunderstanding it. It's details about the commits that I'm after. Thanks. I think I'm on the right track now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Collection of RefChanges contains all the information for the push. getRefId() will give you the name of the branch, getFromHash() will give you the original commit hash and getToHash() will give you the new commit hash. The Settings is for per repository configuration which is configured via the repository hooks admin screens. If you need more information (for instance information about the commits being pushed, or the contents of the files) you should call to HistoryService and ContentService using the approriate commit hashes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
maybe I'm misunderstanding what that object is. I've created a hook, and enabled it in my repository. When I do a push I thought the settings contained an object holding details about my push, so for example the refId pulled from my refChanges object is "refs/heads/master" for the specific commit. I would expect context.getSettings().getString("ref-id") to give me the name of the branch that I'm performing the push against.
Am I misunderstanding what the Settings object is?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you have saved some settings for the repository you are pushing to via the hooks UI and they aren't being reflected in the settings object you are being passed? What settings are you expecting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
(updated to add the full method)
sorry if a double post. My previous comment seems to have disappeared.
No, the object isn't null, and the Settings object doesn't appear to be null either. The following yields an empty Map:
Settings settings = context.getSettings();
Map<String, Object> settingsMap = settings.asMap();
public boolean onReceive(@Nonnull RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse){
hookResponse.out().println("Hello. Thank you for pushing your code. Have a nice day.");
for(RefChange change : refChanges){
hookResponse.out().println(change.getRefId());
hookResponse.out().println(change.getType().name());
}
Settings settings = context.getSettings();
Map<String, Object> settingsMap = settings.asMap();
hookResponse.out().println("Settings size: " + settingsMap.size());
for(Object key : settingsMap.values()){
hookResponse.out().println(key.toString());
}
hookResponse.out().println(context.getSettings().getString("ref-id"));
return true;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you clarify what you mean by RepositoryHookContext being empty. Is it null? is the repository/settings null? Does the settings contain none of the configurations you have saved for your hook?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.