Azure DevOps YAML脚本邮件正文无换行问题求助
解决Azure DevOps YAML邮件正文换行问题
针对你遇到的邮件正文显示为一行的问题,可根据邮件模板支持的格式选择以下方案:
方案1:HTML格式换行(适用于支持HTML的邮件模板)
如果你的sendEmail模板配置的是发送HTML格式邮件,直接在正文里插入HTML换行标签<br>即可:
- template: /templates/python-v1 - template: /templates/sendEmail parameters: to: ${{ parameters.to }} body: "Hi Team,<br>This pull request has encountered errors: $(ERRORMESSAGE)<br><br>Kindly address these issues and resubmit the pull request.<br><br>Thank you.<br><br>Sincerely,<br>[DevOps Team]" from : ${{ parameters.from }} subject : ${{ parameters.subject }}
方案2:纯文本格式换行(适用于纯文本邮件模板)
若模板发送的是纯文本邮件,利用YAML的块标量语法(|)保留原始换行格式,注意内容缩进要和同级参数对齐:
- template: /templates/python-v1 - template: /templates/sendEmail parameters: to: ${{ parameters.to }} body: | Hi Team, This pull request has encountered errors: $(ERRORMESSAGE) Kindly address these issues and resubmit the pull request. Thank you. Sincerely, [DevOps Team] from : ${{ parameters.from }} subject : ${{ parameters.subject }}
如果不确定模板支持哪种格式,可先尝试方案2,块标量语法能直观保留换行结构,多数纯文本邮件模板都能识别。
内容的提问来源于stack exchange,提问作者devendra Padhi
相关产品推荐
相关产品推荐

