Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure FromBase64String返回空字符串_Azure_Azure Pipelines_Azure Powershell - Fatal编程技术网

Azure FromBase64String返回空字符串

Azure FromBase64String返回空字符串,azure,azure-pipelines,azure-powershell,Azure,Azure Pipelines,Azure Powershell,我试图在Azure管道中发送一封带有git提交评论的电子邮件。因为这些注释可以是多行的(而且azure变量不支持多行文本),所以我在powershell脚本任务中将这些注释编码为base64 # get comments through web request $comments_all = "some multiline text" $comments = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($comm

我试图在Azure管道中发送一封带有git提交评论的电子邮件。因为这些注释可以是多行的(而且azure变量不支持多行文本),所以我在powershell脚本任务中将这些注释编码为base64

# get comments through web request
$comments_all = "some multiline text"
$comments = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($comments_all))

Write-Host "-------"
Write-Host $comments
Write-Host "-------"

Write-Host "##vso[task.setvariable variable=commitComment;]$comments"
在下一个(邮件)任务(见下文)中,我尝试解码变量
commitComment
,但它返回一个空字符串(并且不会抛出错误)

我只收到“评论:”和电子邮件正文中的base64代码,但没有解码字符串。我做错了什么

如果我使用

$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("YmxhaGJsYWg=")))
…我得到“布拉布拉”


附带问题:是否有任何方法可以在不必反复运行整个管道进行调试的情况下测试此设置?

经过大量的尝试和错误后,此方法奏效了:

$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("$(commitComment)")))

请注意双引号和附加括号…

您好,非常感谢您在这里分享这个答案!您可以接受这个答案,这样其他用户就可以看到解决方案是否有效:-)谢谢advance@MerlinLiang-MSFT完成了。你知道我如何测试/调试这些东西吗?现在我每次都要运行整个管道,这很不方便。。。
$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("$(commitComment)")))