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

问题描述

我目前正在尝试使用 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

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

谢谢 克里斯托夫

解决方法

查看 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
,

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

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

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

这个版本运行良好。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...