Unable to upload files from gitlab through CI/CD to Nexus Raw Repositories

Hi All,

I am trying to upload files into raw repositories created in the Nexus using curl command from GitLAB CI/CD, I am getting the below error :
Invoke-WebRequest : A positional parameter cannot be found that accepts
argument ‘–upload-file’.

The same curl command when manually run from the command prompt it is working fine ( Files are getting uploaded).
I have tried even removing the alias in the power shell, but no luck,
Requesting you to help on this.

Hi @viwudali
There is no curl in Powershell. However, Microsoft included an alias called curl pointing to Invoke-WebRequest Cmdlet. Parameter --upload-file is not supported by Invoke-WebRequest.
On your command line it most likely works, because you actually have a curl installed locally and configured environment to use it.
When using Powershell I suggest to use native Powershell Cmdlets.

Can you help me with the powershell commands how to upload the files into nexus ?

Dear All ,

Can anyone help me to resolve this issue /

sorry @viwudali but I am not that familiar with Powershell. However, I believe you can use your favorite search engine to find how to upload files with Powershell.

You can do it like this

$user = 'whatever'
$pass = 'whatever'
$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($user, $secpasswd)
Invoke-WebRequest -Credential $credential -AllowUnencryptedAuthentication -Method Put -Infile test.txt -Uri "http://127.0.0.1:8081/repository/gitlab-artifact/test.txt"