powershellamazon-ec2artifactoryjfrog-cliec2-userdata

Powershell Jfrog RT Download leads to NativeCommandError


I am currently trying to create a Powershell script that includes the download of an artifact from jfrog. When running the script, I keep getting

+ jf rt download --url $url --user $username --password $password $repo ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (12:22:58 [Info]... to download...:String) [], RemoteE
   xception
    + FullyQualifiedErrorId : NativeCommandError

when running

jf rt download --url $url --user $username --password $password $repo/$ArtifactPath $PlatformZipPath --flat

even so the jf ping works just fine

jf rt ping --url $url --user $artifactdetails.username --password $artifactdetails.password

The Powershell script is run in the User Data section of an EC2 instance.

Additionally, when I add $ErrorActionPreference = "Stop" to the script, I get these errors.

PS>TerminatingError(jf.exe): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 12:22:58 [Info] Searching items to
 download..."
>> TerminatingError(jf.exe): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 12:22:58 [Info] Searching items to
 download..."
>> TerminatingError(jf.exe): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 12:22:58 [Info] Searching items to
 download..."
>> TerminatingError(jf.exe): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 12:22:58 [Info] Searching items to
 download..."
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 12:22:58 [Info] Searching items to download...
jf : 12:22:58 [Info] Searching items to download...
At

Solution

  • We solved the issue by adding cmd to the command itself.

    & cmd /c "jf rt download --url=$url --user $username --password $password $repo/$ArtifactPath $PlatformZipPath --flat --fail-no-op 2>&1"