How to use Soy Templates (inline or not)

855 views
Skip to first unread message

TonyMontana

unread,
Apr 3, 2019, 4:04:20 AM4/3/19
to Repo and Gerrit Discussion
Hi,
I have recently started testing the its-jira-plugin and I have trouble understanding how to use Soy comments. I find that the documentation does not really help me. I'd like to be able to include more information in the messages sent to Jira, especially for the events that don't have a standard comment. I just don't understand how to use them. What is the syntax like when using an inline template for instance?
Example:

action = add-soy-comment {$its.formatLink($changeUrl)} positive comment

Is this correct? Is there a list of variables I can use somewhere? I have no idea where its.formatLink or changeUrl comes from, how can I test it? So far I'm not able to get anything through. I think inline templates would be enough for me but I'd like to be able to write separate template files as well. Does anyone have any good examples?

Generally though, how are the templates used and how can I test them?

Best,

Alon Bar-Lev

unread,
Apr 3, 2019, 4:12:59 AM4/3/19
to TonyMontana, Repo and Gerrit Discussion
Hi,
It took me a while as well...
See examples below.
Regards,
Alon

---

etc/its/actions.config:
---
[rule "created"]
    event-type = patchset-created
    association = added@footer-Bug, added@footer-Related-To, added@footer-Task
    action = add-soy-comment created
[rule "merged"]
    event-type = change-merged
    association = footer-Bug, footer-Related-To, footer-Task
    action = add-soy-comment merged
---

etc/its/templates/created:
---
{namespace etc.its.templates}

/**
 * @param changeNumber
 * @param formatChangeUrl
 * @param project
 * @param branch
 * @param uploaderName
 * @param subject
 */
{template .created kind="text"}
  Gerrit change {$changeNumber} {$formatChangeUrl} for {$project}/{$branch} uploaded by {$uploaderName}
  {\n}
  {$subject}
{/template}

---

etc/its/templates/merged:
---
{namespace etc.its.templates}

/**
 * @param changeNumber
 * @param formatChangeUrl
 * @param project
 * @param branch
 * @param uploaderName
 * @param subject
 */
{template .merged kind="text"}
  Gerrit change {$changeNumber} {$formatChangeUrl} for {$project}/{$branch} merged by {$uploaderName}
  {\n}
  {$subject}
{/template}
---


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyMontana

unread,
Apr 8, 2019, 10:34:13 AM4/8/19
to Repo and Gerrit Discussion
Thank you very much for the information.

I couldn't get the template to work.
I tried one of your lines with slight modifications as a velocity-comment and it worked. Do you know what I need to get soy comments working? I'm running Gerrit 2.14.18, I have its-base and its-jira installed.
Is anything additional needed for soy comments/templates?

Best

Alon Bar-Lev

unread,
Apr 9, 2019, 4:27:30 PM4/9/19
to TonyMontana, Repo and Gerrit Discussion
Hi,

What have you tried? My previous examples?

The documentation is available here[1], I am also using its-jira but gerrit 2.16 and it works properly for me.

Regards,
Alon


--
Reply all
Reply to author
Forward
0 new messages