6

I want to deploy aws lamda .net core project using bit bucket pipeline

I have created bitbucket-pipelines.yml like below but after build run getting error -

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

file code -

image: microsoft/dotnet:sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script: # Modify the commands below to build your repository.
          - export PROJECT_NAME=TestAWS/AWSLambda1/AWSLambda1.sln
          - dotnet restore
          - dotnet build $PROJECT_NAME
          - pipe: atlassian/aws-lambda-deploy:0.2.1
            variables:
              AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
              AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
              AWS_DEFAULT_REGION: 'us-east-1'
              FUNCTION_NAME: 'my-lambda-function'
              COMMAND: 'update'
              ZIP_FILE: 'code.zip'

project structure is like this -

enter image description here

Neo
  • 15,491
  • 59
  • 215
  • 405

1 Answers1

9

The problem is here:

PROJECT_NAME=TestAWS/AWSLambda1/AWSLambda1.sln

This is the incorrect path. Bitbucket Pipelines will use a special path in the Docker image, something like /opt/atlassian/pipelines/agent/build/YOUR_PROJECT , to do a Git clone of your project.

You can see this when you click on the "Build Setup" step in the Pipelines web console:

Cloning into '/opt/atlassian/pipelines/agent/build'...

You can use a pre-defined environment variable to retrieve this path: $BITBUCKET_CLONE_DIR , as described here: https://support.atlassian.com/bitbucket-cloud/docs/variables-in-pipelines/

Consider something like this in your yml build script:

script:
  - echo $BITBUCKET_CLONE_DIR # Debug: Print the $BITBUCKET_CLONE_DIR
  - pwd # Debug: Print the current working directory
  - find "$(pwd -P)" -name AWSLambda1.sln # Debug: Show the full file path of AWSLambda1.sln

  - export PROJECT_NAME="$BITBUCKET_CLONE_DIR/AWSLambda1.sln"
  - echo $PROJECT_NAME
  - if [ -f "$PROJECT_NAME" ]; then echo "File exists" ; fi

  # Try this if the file path is not as expected
  - export PROJECT_NAME="$BITBUCKET_CLONE_DIR/AWSLambda1/AWSLambda1.sln"
  - echo $PROJECT_NAME
  - if [ -f "$PROJECT_NAME" ]; then echo "File exists" ; fi
Mr-IDE
  • 7,051
  • 1
  • 53
  • 59