Powershell JiraPS - 使用 Get-JiraIssueAttachmentFile 下载附件仅返回 true 但没有文件

时间:2021-02-16 12:35:27

标签: powershell jira jira-rest-api

我目前正在尝试使用 Powershell cmdlet JiraPS 从 Jira Server 下载附件。

验证和建立会话工作正常。 也可以使用函数“Get-JiraIssueAttachment”获取附件信息。

但是当我尝试使用“Get-JiraIssueAttachmentFile”下载实际文件时,我只得到“True”作为输出,但文件没有被下载。

在另一个方向它起作用。我可以上传附件。 而且我还可以在网络界面中下载附件。

所以目前我不知道如何继续:

我当前的代码是:

$JiraUrl = "http://jira:8080"
$UserName = "admin"
$Password = "***" 
$global:response

$secure_pwd = $Password | ConvertTo-SecureString -AsPlainText -Force
$JiraCredentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $secure_pwd
$null = Set-JiraConfigServer -Server $JiraUrl
$null = New-JiraSession -Credential $JiraCredentials -ErrorVariable errorVar

$JAttach = Get-JiraIssue PRJ-351 | Get-JiraIssueAttachment -FileName "FiddlerSetup.exe"

Get-JiraIssueAttachmentFile -Attachment $JAttach

有没有人设法让它运行? 任何提示将不胜感激

谢谢 克里斯托夫

2 个答案:

答案 0 :(得分:0)

查看 documentation Get-JiraIssueAttachment 返回一个布尔值而不是文件本身。如果您不传递 -path 参数,它会下载到当前工作目录。您可以使用 Get-ChildItem 将文件分配给您的变量。

$JiraUrl = "http://jira:8080"
$UserName = "admin"
$Password = "***" 
$global:response

$secure_pwd = $Password | ConvertTo-SecureString -AsPlainText -Force
$JiraCredentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $secure_pwd
$null = Set-JiraConfigServer -Server $JiraUrl
$null = New-JiraSession -Credential $JiraCredentials -ErrorVariable errorVar

Get-JiraIssue PRJ-351 | Get-JiraIssueAttachment -FileName "FiddlerSetup.exe"
$Jattach = Get-ChildItem FiddlerSetup.exe
   
Get-JiraIssueAttachmentFile -Attachment $JAttach

答案 1 :(得分:0)

感谢您的反馈。 与此同时,我又做了一些研究。

出于某种原因,我们从 powershellgallery 获得了旧版本 (2.9)。

当前版本是2.14,我是从github仓库(https://github.com/AtlassianPS/JiraPS/tree/v2.14)下载的

这个版本运行良好。