18. SECTION TITLE 1
HOOKS
Pre receive hook
atlassian-plugin.xml
<pre-receive-hook
key="mySummitHook"
name="Summit 2013 Pre-receive Hook"
class="nl.stefankohler.stash.hook.MySummitHook">
<description>
A pre-receive hook that will block all actions
after the Summit Bash
</description>
</pre-receive-hook>
19. SECTION TITLE 1
HOOKS
Pre receive hook
MySummitHook.java
public class MySummitHook implements PreReceiveHook {
/**
* Disables all actions after the Summit Bash.
*/
@Override
public boolean onReceive(Repository repository,
Collection<RefChange> refChanges,
HookResponse hookResponse) {
DateTime summitBash = new DateTime(2013, 10, 2, 19, 0);
if (summitBash.isBeforeNow()) {
hookResponse.err.println("Pushing is disabled " +
"after the Summit Bash, don't drink & code!");
return false;
}
return true;
}
}
24. EVENTS
Repository Push Event
MySummitPushEvent.java
public class MySummitPushEvent {
@EventListener
public void notifyTwitter(
RepositoryPushEvent pushEvent) {
}
}
twitterClient.tweet("A push was made to " +
pushEvent.getRepository())
28. INDEXER
Dos & Don’ts
Don’t do expensive operations
Don’t handle the same changeset twice
Do consider memory usage
Do consider bulk processing
Do consider security
45. Rate this Talk
Starting on Stash
Text code below to 22333
or visit http://bit.ly/19JRN5S
MEH = Z
NO T BA D = 10
P R ET T Y GO O D = 11
A WES O ME = 12
To join this session, send text 136888 to