Automatic builds using BitBucket

10 months ago
Hi there,

I'm trying to setup automatic builds when code is pushed to BitBucket.
However, I'm having trouble getting the plugins to build and output to the correct folder structure.

Anyone else using BitBucket and automatic builds?

Any help would be appreciated.

Best regards,
Peter
10 months ago
Hi Peter,

Do you see any errors when trying to build them? Can you share your build pipeline ?

Thanks
9 months ago
Sorry for the late reply, but I have been on vacation. :)

Below is the current .yml script, it includes some test code for trying to figure out where things are located etc.

I also tried to build the plugins separately, but I can't get it to work, this is the first time I've been trying to set builds using .yml  files, so any help would be apreciated.

Best regards,
Peter

#  Template .NET Core build

#  This template allows you to validate your .NET Core package.
#  The workflow allows running tests and code linting on the default branch.

# To run your pipeline on a Windows machine, create a self-hosted Windows runner.
# For instructions on setting up a Windows runner, see https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-windows/

image: mcr.microsoft.com/dotnet/core/sdk:2.2

pipelines:
  default:
        - step:
            name: Build and Test
            caches:
              - dotnetcore
            script:
              - REPORTS_PATH=./test-reports/build_${BITBUCKET_BUILD_NUMBER}
              - dotnet restore ./src/NopCommerce.sln
              - dotnet build ./src/NopCommerce.sln --no-restore --configuration Release
              - ls -l /opt/atlassian/pipelines/agent/build/src/Presentation/Nop.Web/Plugins/Misc.AzureBlobSync/
        - step:
            name: Publish
            caches:
              - node
              - dotnetcore
            #trigger: manual  # Uncomment to make this a manual deployment.
            script:
              - apt-get update
              - apt-get install zip -y
              #- dotnet restore ./src/NopCommerce.sln
              - dotnet publish ./src/Presentation/Nop.Web/Nop.Web.csproj --configuration release --output ./publish
              #- dotnet publish --configuration release --no-restore ./src/Presentation/Nop.Web/Nop.Web.csproj -o ./publish
              #- dotnet publish --configuration release --no-restore ./src/Plugins/Nop.Plugin.Payments.Ariba/Nop.Plugin.Payments.Ariba.csproj
              #- dotnet publish --configuration release --no-restore ./src/Plugins/Nop.Plugin.Payments.Hansa/Nop.Plugin.Payments.Hansa.csproj
              #- ls -l ./src/Presentation/Nop.Web/Plugins/Payments.Ariba
              #- ls -l ./src/Presentation/Nop.Web/Plugins/Payments.Hansa
              #- rm ./src/Presentation/Nop.Web/publish/Plugins/Payments.Hansa/plugin.json
              - zip -r nopCommerce_${BITBUCKET_BUILD_NUMBER}.zip ./src/Presentation/Nop.Web/publish
              - ls -l
              - ls -l ./src
              - ls -l /opt/atlassian/pipelines/agent/build/src/Presentation/Nop.Web/publish/
            artifacts:
              - nopCommerce_*.zip
9 months ago
Ok, so I put some work into this today and got a basic working artifact with some json files removed so they don't overwrite existing files.

Will add tests and so on, but the actual output was the important thing.

image: mcr.microsoft.com/dotnet/core/sdk:2.2

pipelines:
  default:
    - step:
        name: Build and Publish
        script:
          - dotnet restore ./src/NopCommerce.sln
          - dotnet build ./src/NopCommerce.sln --no-restore --configuration Release
          - dotnet publish ./src/Presentation/Nop.Web/Nop.Web.csproj --no-build --configuration Release --output $BITBUCKET_CLONE_DIR/release
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Ariba/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.CheckMoneyOrder/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Hansa/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Manual/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PayPalSmartPaymentButtons/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PayPalStandard/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PurchaseOrder/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.SwedbankPay/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/App.config
          - rm $BITBUCKET_CLONE_DIR/release/appsettings.json
          - rm $BITBUCKET_CLONE_DIR/release/web.config
          - rm -r $BITBUCKET_CLONE_DIR/release/App_Data

        artifacts:
          - release/**
9 months ago
Great. May be you could share the complete pipeline when its ready. It will be helpful for community!

All the best.

nopAccelerate
8 months ago
For others that may have the same problem this is the pipeline I came up with.

This will build, then create a zip file and send it via ftp to a defined server, just replace the user,password and serveraddress to your own.

image: mcr.microsoft.com/dotnet/core/sdk:2.2

pipelines:
  default:
    - step:
        name: Build and Publish
        script:
          - dotnet restore ./src/NopCommerce.sln
          - dotnet build ./src/NopCommerce.sln --no-restore --configuration Release
          - dotnet publish ./src/Presentation/Nop.Web/Nop.Web.csproj --no-build --configuration Release --output $BITBUCKET_CLONE_DIR/release
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Ariba/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.CheckMoneyOrder/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Hansa/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.Manual/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PayPalSmartPaymentButtons/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PayPalStandard/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.PurchaseOrder/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/Plugins/Payments.SwedbankPay/plugin.json
          - rm $BITBUCKET_CLONE_DIR/release/App.config
          - rm $BITBUCKET_CLONE_DIR/release/appsettings.json
          - rm $BITBUCKET_CLONE_DIR/release/web.config
          - rm -r $BITBUCKET_CLONE_DIR/release/App_Data

        artifacts:
          - release/**
    - step:
        name: Deployment file
        image: atlassian/default-image:2
        script:
          - mkdir $BITBUCKET_CLONE_DIR/tmp
          - cd $BITBUCKET_CLONE_DIR/release
          - zip -r nopCommerce_${BITBUCKET_BUILD_NUMBER}.zip .
          - mv nopCommerce_${BITBUCKET_BUILD_NUMBER}.zip $BITBUCKET_CLONE_DIR/tmp/
          - apt-get update
          - apt-get install -y lftp
          - cd $BITBUCKET_CLONE_DIR/tmp && lftp -e "set ftp:ssl-allow no; put nopCommerce_${BITBUCKET_BUILD_NUMBER}.zip; bye" -u ftploginname,ftppassword ftpserver
        artifacts:
          - tmp/nopCommerce_*.zip
8 months ago
Very useful for everyone, thanks for sharing. +1