Skip to content

Commit

Permalink
support templates for gitlab issue descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssadedin committed Sep 4, 2024
1 parent c6ca6f3 commit 2fb419f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/Guides/Gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ as an attachment. For example:
) to channel: 'gitlab', file: input.png
```

## Description Templates

You can use a template file for the description if you wish. To do this:

- ensure any variables needed in the template are included in the `issue(...)` section as attributes
- add a `template : "<path to your template file>"` attribute also.
- do not include the description attribute

For example:

```
send issue(
title: 'Results of Experiment',
template: 'templates/experiment_results.md'
) to channel: 'gitlab', file: input.png
```

## Gitlab Actions

You can cause various actions to occur such as adding and removing labels, assigning issues
Expand Down
3 changes: 3 additions & 0 deletions src/main/groovy/bpipe/NotificationManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ class NotificationManager {
templateName = cfg.template
}
}
else {
log.info "Using template $templateName for notification $evt"
}

// Is it customized for this event?
if(cfg.containsKey("templates")) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/groovy/bpipe/Sender.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class Sender {
*/
def content

/**
* Some sender contexts may specify a template explicitly
*/
String template

String defaultSubject

Map details = [:]
Expand Down Expand Up @@ -113,6 +118,8 @@ class Sender {

Sender issue(Map details) {
this.content = details
if(details?.template)
this.template = details.template
this.contentType = "application/json"
this.defaultSubject = details.title
return this
Expand Down Expand Up @@ -284,6 +291,14 @@ class Sender {
"send.branch" : ctx.branch.name
]

if(this.template) {
log.info "Template $template found in notification details"
props["template"] = this.template
}
else {
log.info "No template in details"
}

if('url' in details) {
props["send.url"] = details.url
}
Expand Down

0 comments on commit 2fb419f

Please sign in to comment.