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

Jira创建Issue时,数组填充描述表格返回undefined如何解决

问题原因与解决方法

问题出在你使用的forEach方法上:Array.prototype.forEach()没有返回值,执行后默认返回undefined,所以模板字符串中插入的部分就是undefined,导致表格行无法生成。

解决步骤

  1. 替换forEach为map:map方法会遍历数组,返回由每个元素处理后的结果组成的新数组,正好适合生成表格行的字符串集合。
  2. 用join('')拼接数组:把map返回的字符串数组拼接成完整的文本,插入到模板字符串中。

修改后的代码如下:

const data = {
    fields: {
        project: {
            key: config.jira.project
        },
        summary: "Migration Tool - Migrating repositories",
        description: `Migrating repositories\n
Validated Bitbucket repositories:\n
||ID||Bitbucket Key||Bitbucket repo slug||Github Organization||Github repo name||
${input.validated.map(item => {
    return `|${item.id}|${item.bitbucket.projectKey}|${item.bitbucket.repositoryName}|${item.github.org}|${item.github.repositoryName}|\n`
}).join('')}
            
Invalid Bitbucket repositories:\n`,
        issuetype: {
            name: "Task"
        },
        customfield_10005: config.jira.epic
    }
}

额外提示

  • 注意模板字符串的缩进:如果保留过多前置空格,可能导致Jira无法正确解析表格格式,建议表格行的文本不要带多余缩进。
  • 如果input.validated是空数组,map会返回空数组,join后是空字符串,不会影响表格的表头显示。

内容的提问来源于stack exchange,提问作者Alistair Hardy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 01:06:25