Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Starting on Stash

680 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Starting on Stash

  1. 1. Starting on Stash STEFAN KOHLER • CONSULTANT • 42 BV • @STEFANKOHLER
  2. 2. Who am I
  3. 3. Stefan Kohler • Atlassian Expert • Add-on Developer and CodeGeist addict • AUG Founder • Author of Confluence book http://amzn.to/15xQIiT
  4. 4. Notifyr
  5. 5. Just text by itself, for impact.
  6. 6. Badgr
  7. 7. Just text by itself, for impact.
  8. 8. The Idea
  9. 9. Write down your ideas, to make them real and make room for new ideas
  10. 10. Research your idea • Another add-on available? • It is a requested feature? • JIRA • Answers • Contact a Product Manager
  11. 11. JIRA Votes
  12. 12. Notifyr Idea
  13. 13. Getting Hooked H ooks Ev ent s Indexer
  14. 14. HOOKS Custom scripts that are executed when certain actions occur.
  15. 15. Repository Hooks
  16. 16. SECTION TITLE 1 HOOKS Available Hooks • Pre-receive BLOCKING • Asynchronous Post-receive • Merge-checks BLOCKING
  17. 17. 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>
  18. 18. 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; } }
  19. 19. Getting Hooked H ooks Ev ent s Indexer
  20. 20. EVENTS Events are triggered throughout Stash, just listen for them!
  21. 21. S E C TEO NNT IS L E 1 I VE T T Available Events
  22. 22. EVENTS Repository Push Event atlassian-plugin.xml <component key="MySummitPushEvent" class="nl.stefankohler.stash.events.MySummitPushEvent" />
  23. 23. EVENTS Repository Push Event MySummitPushEvent.java public class MySummitPushEvent { @EventListener public void notifyTwitter( RepositoryPushEvent pushEvent) { } } twitterClient.tweet("A push was made to " + pushEvent.getRepository())
  24. 24. Getting Hooked H ooks Ev ent s Indexer
  25. 25. INDEXER Get in the Stash indexing pipeline to get data from, or add data to a commit
  26. 26. INDEXER
  27. 27. 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
  28. 28. INDEXER Changeset Indexer atlassian-plugin.xml <changeset-indexer key="SummitIndexer" class="nl.stefankohler.stash.indexer.SummitIndexer" />
  29. 29. INDEXER Changeset Indexer SummitIndexer.java public class SummitIndexer implements ChangesetIndexer { ... @Override public void onChangesetAdded( @Nonnull Changeset changeset, @Nonnull IndexingContext ctx) { if (changeset.getMessage().contains("summit")) { ctx.put("duringSummit", true); } } ... }
  30. 30. Got Service?
  31. 31. Services allow you to get and add data from and to Stash
  32. 32. Services Users UserService Change history HistoryService Project ProjectService Repository RepositoryServic
  33. 33. Services https://developer.atlassian.com/static/ javadoc/stash/latest/api
  34. 34. Access to services public class BadgrChangesetIndex implements ChangesetIndexer { public BadgrChangesetIndex( HistoryService historyService, LoggingService loggingService) { } } this.historyService = checkNotNull(historyService); ...
  35. 35. Look the part
  36. 36. Atlassian Design Guidelines
  37. 37. Soy is the best thing that happened to templates
  38. 38. Soy • One template for server and client side • Separation between logic and display • Reuse of widgets • JavaScript
  39. 39. AUI comes with Soy widgets!
  40. 40. Next...
  41. 41. Documentation and Examples
  42. 42. Resources • http://developer.atlassian.com • http://developer.atlassian.com/design • https://developer.atlassian.com/stash/ • Use the source code for examples and reference #atlassiansummit
  43. 43. Thank you! STEFAN KOHLER • CONSULTANT • 42 BV • @STEFANKOHLER
  44. 44. 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

×