You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Confluence禁用HTML宏时嵌入内部站点响应的技术方案咨询

Embed /ping Endpoint Responses in Confluence Tables (No HTML Macro)

Great question! Since your Confluence instance has HTML macros disabled, there are a few practical approaches to embed your internal sites' /ping responses into table columns—covering both plain text and formatted content like math formulas.

Basic Need: Embed Plain Text /ping Responses

Here are two reliable methods depending on the tools you have available:

If your team uses the Script Runner add-on (common in enterprise Confluence instances), you can create a reusable Groovy script macro to fetch and display the /ping response:

  1. Go to Confluence Admin > Script Runner > Create Script Macro
  2. Name it FetchPingResponse, set it to render inline, and add a url parameter for the target /ping endpoint
  3. Use this script:
import com.atlassian.sal.api.component.ComponentAccessor

def urlParam = getParameter("url")
if (!urlParam) return "Missing URL parameter"

// Optional: Add caching to reduce repeated API calls
def cacheManager = ComponentAccessor.getCacheManager()
def cache = cacheManager.getCache("pingResponseCache")
def cachedResponse = cache.get(urlParam)

if (cachedResponse) {
    return cachedResponse
}

// Fetch the /ping response
def connection = new URL(urlParam).openConnection()
connection.setRequestMethod("GET")
connection.setConnectTimeout(5000) // Timeout after 5s to avoid hanging pages
def response = connection.inputStream.text

// Cache the response for 60 seconds (adjust as needed)
cache.put(urlParam, response, 60)
return response
  1. In your table's target cell, call the macro like:
    {fetch-ping-response:url=https://your-internal-site/ping}

2. Custom User Macro (No Add-ons Required)

If you can't use Script Runner, create a native Confluence user macro to handle the HTTP request:

  1. Go to Confluence Admin > User Macros > Create a User Macro
  2. Set:
    • Macro name: fetchping
    • Visibility: Visible to all users
    • Macro body: None
    • Template: Use this Velocity code:
#set($url = $paramUrl)
#if (!$url)
    Missing 'url' parameter
#else
    #set($httpService = $action.getService("com.atlassian.confluence.plugins.confluence-http-plugin:httpService"))
    #try
        #set($response = $httpService.get($url).getEntity().getContent().getText())
        $response
    #catch($e)
        Failed to fetch response: $e.getMessage()
    #end
#end
  1. Use it in your table cell with:
    {fetchping:url=https://your-internal-site/ping}

Note: Ensure your Confluence instance is allowed to make outbound requests to your internal sites (check your network firewall and Confluence's outbound HTTP whitelist).


Advanced Need: Handle Formatted /ping Responses (Math Formulas, Markdown, etc.)

If your /ping endpoint returns structured content like LaTeX math formulas or Markdown, you'll need to convert that content to Confluence-compatible markup before rendering.

1. LaTeX Math Formulas

If the /ping response is raw LaTeX (e.g., E=mc^2), modify your macro to wrap the response in Confluence's built-in math macro syntax:

Script Runner Script Adjustment:

// ... (keep the caching/fetch logic from before)
def latexResponse = connection.inputStream.text
// Wrap LaTeX in Confluence's math macro
return "{math:$latexResponse}"

Confluence will automatically render this as a properly formatted math formula.

2. Markdown Content

If the /ping response uses Markdown, use Confluence's built-in Markdown parser to convert it to Confluence Wiki markup:

Custom User Macro Adjustment:

#set($url = $paramUrl)
#if (!$url)
    Missing 'url' parameter
#else
    #set($httpService = $action.getService("com.atlassian.confluence.plugins.confluence-http-plugin:httpService"))
    #try
        #set($markdownContent = $httpService.get($url).getEntity().getContent().getText())
        #set($markdownParser = $action.getService("com.atlassian.confluence.plugins.markdown:markdownParser"))
        #set($wikiMarkup = $markdownParser.convertToWikiMarkup($markdownContent))
        $wikiMarkup
    #catch($e)
        Failed to fetch/parse response: $e.getMessage()
    #end
#end

This will convert Markdown headers, lists, and formatting into Confluence's native style.

3. Confluence Wiki Markup

If the /ping response already uses Confluence's own wiki syntax, you can output it directly—Confluence will render it automatically without extra conversion.


内容的提问来源于stack exchange,提问作者Darius X.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:40:30