Search code examples
.net-coregitlabpipelinecicdapt-get

Gitlab - Getting error while deploying .net core application. apt-get package giving error


I have setup Gitlab pipeline for my repository. I am getting error on deployment. Below is my deploy script.

script:

# cd to where csproj is
- cd $deploy_path
# publish the files - this will generate the publish files in bin/release 
- dotnet publish -c release
# install zip and lftp
- apt-get update -qq && apt-get install -y -qq zip lftp 
# cd to bin
- cd bin
# zip release, name zip CreativelyCode.zip
- mkdir prep
- zip -r CreativelyCode release
# upload file to ftp
- lftp -e "set ssl:verify-certificate no; lpwd; open $FTP_HOST; user $FTP_USERNAME $FTP_PASSWORD; put -O /files/ CreativelyCode.zip; bye"

Below is the error screenshot.

enter image description here

If I make separate app-get commands, I get below error.

enter image description here

I have used this as reference for my script. I trying to deploy files to FTP server. Any help is greatly appreciated. Thanks.


Solution

  • Thanks for the response @m-eriksen and @Perry. Yes...The reason for this error was I was running bash commands in PowerShell. So I changed bash commands with PowerShell commands to achieve my task as follows .

         - '$source = "release"'
         - '$destination = "ftp://username:password@hostname/destination"'
         - '$webclient = New-Object -TypeName System.Net.WebClient'
         - '$files = Get-ChildItem $source'
         - 'foreach ($file in $files){Write-Host "Uploading $file"   $webclient.UploadFile("$destination/$file", $file.FullName)}' 
         - '$webclient.Dispose()'
    

    I know this is not the ideal solution. But as I am playing with Gitlab this will really help me to start with it.