Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zip directory in BitBucket pipeline using image microsoft/dotnet:sdk

In a bitbucket-pipelines.yml BitBucket Pipeline file I am trying to publish a DotNet Core solution, zip it into the correct form to be understood by AWS and then upload it S3.

My build is based on the image microsoft/dotnet:sdk.

image: microsoft/dotnet:sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script:
          - dotnet restore
          - dotnet publish MyProj/MyProj.csproj -o ../output
          - 7z a output.zip .\output\*
          - 7z a MyPackage.zip service.zip aws-windows-deployment-manifest.json

This step fails on the first 7z command because 7Zip isn't installed. What is the best way from the Windows command line to zip these files? Alternatively, is there a different Docker image I should be using?

like image 453
infojolt Avatar asked Oct 24 '25 17:10

infojolt


1 Answers

I'm using Amazon.Lambda.Tools to deploy and had a similar issue where I needed to install zip - you could use zip to do it, or install 7z and use that - just need a couple of extra commands to apt-get

If you use a deployment step you'll also get CI/CD metrics and visuals in BitBucket (this is my config)

image: microsoft/dotnet:sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script:
          - dotnet restore
          - dotnet build
          - dotnet test
    - step:
        deployment: test
        script:
          - dotnet tool install -g Amazon.Lambda.Tools
          - export PATH="$PATH:/root/.dotnet/tools"
          - apt-get update
          - apt-get install zip -y # or install 7z instead
          - dotnet lambda deploy-serverless --region $...... # or manually upload to S3
like image 180
Alex Hinton Avatar answered Oct 27 '25 03:10

Alex Hinton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!