Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Sometimes, it is required to dynamically allocate the macro content for template purposes or other re-using reasons. For this, it might be necessary for the user to make the macros' parameters externally available. In the following sections we present two examples that help users creating scripts for automation. 

Create a new User Macro

1) In the administration section go to the user macro section

2) Create new user macro

3) Define name and title for the user macro 

4) Fill in the code in the mandatory Template field. The template content depends on what you like to include. The following examples show some possibilities. It is important to define the required parameters so that you can access them via the User macro.

4.a Define a Template to include a file from Bitbucket Server with User Macro Template Syntax

## This is an example macro
## @param repoSlug=Name|type=string|required=true
## @param projectKey=Name|type=string|required=true

<ac:structured-macro ac:name="stashbranches">
	<ac:parameter ac:name="repoSlug">$paramrepoSlug</ac:parameter>
	<ac:parameter ac:name="projectKey">$paramprojectKey</ac:parameter>
</ac:structured-macro>

This definition makes it now possible to access the Include for Bitbucket Server Macro parameters via Wiki markup syntax in the User Macro:

This renders the following output:


4.b Define a Template to include the latest Commits from a Bitbucket Server project

Macro name: include-bss-commits-wrapper-macro

## @param repoSlug:title=Repo Slug|required=true
## @param branchId:title=Branch Id|required=true
## @param projectKey:title=Project Key|required=true

<ac:structured-macro ac:name="stashcommits">
<ac:parameter ac:name="repoSlug">$paramrepoSlug</ac:parameter>
<ac:parameter ac:name="branchId">$parambranchId</ac:parameter>   
<ac:parameter ac:name="projectKey">$paramprojectKey</ac:parameter>
</ac:structured-macro>


Add user macro with wiki markup on a page:


This renders the following output:


References:

User Macro Template Syntax

Allow Macro content inside any other Macro


Wiki Markup 





  • No labels