吉拉制造了问题.从数组中插入内联文本



我正试图以编程方式在Jira中为我正在编写的迁移工具创建一个表。在描述中,有一个表保存了所有的源和目标信息。但是,我无法获得要填充的表。我的通话数据如下。

const data={
fields:{
project:{
key: config.jira.project
},
summary:"Migration Tool - Migrating repositories",
description: `Migating repositoriesn
Validated Bitbucket repositories:n
||ID||Bitbucket Key||Bitbucket repo slug||Github Organization||Github repo name||
${input.validated.forEach(item => {
return (`|${item.id}|${item.bitbucket.projectKey}|${item.bitbucket.repositoryName}|${item.github.org}|${item.github.repositoryName}|n`)
// console.log(validatedTable(item))
// return(validatedTable(item))
})}

Invalid Bitbucket repositories:n`,
issuetype:{
name:"Task"
},
customfield_10005: config.jira.epic
}
}

目前,它正在返回undefined。如何使文本也返回并填充表格?

如上所述,我不喜欢尝试从字符串内部构建文本字符串。

我的解决方案是将字符串构建到变量中,然后调用该变量。

var validatedString = ""
var invalidatedString = ""
for (const item of input.validated) {
validatedString = validatedString + `|${item.id}|${item.bitbucket.projectKey}|${item.bitbucket.repositoryName}|${item.github.org}|${item.github.repositoryName}|n`
}
for (const item of input.invalidated) {
invalidatedString = invalidatedString + `|${item.id}|${item.bitbucket.projectKey}|${item.bitbucket.repositoryName}|${item.github.org}|${item.github.repositoryName}|${item.error.message}n`
}
const data={
fields:{
project:{
key: config.jira.project
},
summary:"Migration Tool - Migrating repositories",
description: `Migating repositoriesn
Validated Bitbucket repositories:n
||ID||Bitbucket Key||Bitbucket repo slug||Github Organization||Github repo name||
${validatedString}n
Invalid Bitbucket repositories:n
||ID||Bitbucket Key||Bitbucket repo slug||Github Organization||Github repo name||Error||
${invalidatedString}`,
issuetype:{
name:"Task"
},
customfield_10005: config.jira.epic
}
}

我必须在末尾用=""声明变量,否则字符串的第一部分总是有undefined

最新更新