How to modify soy templates in a stash repository hook built from scratch

I am trying to create a stash post-receive repository hook. I followed the "Starting from scratch" guide located at https://developer.atlassian.com/stash/docs/latest/how-tos/creating-a-stash-plugin.html.

After installing the atlassian SDK and its dependencies, I executed these commands:

  • atlas-create-stash-plugin
  • cd myplugin
  • atlas-create-stash-plugin-module

I then ran atlas-debug, opened Firefox, went to the Stash URL provided by atlas-debug, and verified that the plugin shows up on the repository hooks page for Project 1 / rep_1. When I clicked "Enabled", a form appeared with a text field to enter the url. The description for the text field said "Some description for url".

As a quick test, I wanted to try changing the description to something else. I opened "src/main/resources/static/my-hook.soy", changed the description to be "foo bar", and saved the file.

Next, I re-ran atlas-debug and went back to Firefox to enable the plugin again. After clicking "Enabled" for the plugin, I noticed the description of the text field said "Some description for url" instead of "foo bar". It did not seem to be picking up my modifications to the .soy file.

My attempts to fix the problem include:

  • running atlas-run instead of atlas-debug. Still no "foo bar".
  • run atlas-clean, then run atlas-debug and/or atlas-run. Still no "foo bar"
  • changing "foo bar" to "my foo bar". Still no "my foo bar".

I also grepped for "Some description for url", in case it was coming from somewhere other than the .soy template but could not find any references to it.

Am I missing something here? Is there something I am supposed to do to get my .soy file changes to take affect?

For your reference, atlas-version says:

ATLAS Version: 4.2.0
ATLAS Home: /usr/share/atlassian-plugin-sdk-4.2.0
ATLAS Scripts: /usr/share/atlassian-plugin-sdk-4.2.0/bin
ATLAS Maven Home: /usr/share/atlassian-plugin-sdk-4.2.0/apache-maven
--------
Executing: /usr/share/atlassian-plugin-sdk-4.2.0/apache-maven/bin/mvn --version -gs /usr/share/atlassian-plugin-sdk-4.2.0/apache-maven/conf/settings.xml
Apache Maven 2.1.0 (r755702; 2009-03-18 14:10:27-0500)
Java version: 1.6.0_43
Java home: /usr/lib/jvm/java-6-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.2.0-36-generic" arch: "amd64" Family: "unix"

Thanks!

1 answer

1 accepted

Hi John,

I think there are some minor issues around our caching of plugins on restart. The good news is that by using 'atlas-cli' and then 'pi' you can both avoid this issue and not have to restart your server every time.

https://answers.atlassian.com/questions/155558/how-to-reload-plugin-during-dev-without-restarting

Let me know if that helps.

Charles

Thank you for the assisstance, Charles.

I ran the following commands:

  • atlas-cli
  • pi

After that, I refreshed the Hooks page and clicked "Enabled" again. Unfortunately, the description still said "Some description for url" instead of "foo bar".

Next, I completely cleared everything in Firefox's cache. After doing that, "foo bar" started to appear. My problem is now solved.

This experience was very frustrating for me. In case you or anyone else who reads this is capable of improving the experience of plugin developers, here are some suggestions:

  • If atlas-cli is the recommended way to debug plugins, then it should be mentioned in the guide I referenced in my first post.
  • If the caching behavior of soy templates that I experienced is the intended behavior, then it should be documented. If it is already documented, then maybe it should be easier to find because I could not find it.
  • I should not have to clear my web browser's cache after re-installing my plugin during an atlas-debug session. The HTTP server could send a "Cache-Control: no-cache" HTTP header to prevent web resources from being cached locally while debugging.

Thank you again, Charles. Your timely response was very much appreciated.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

171 views 20 8
Join discussion

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