PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 27, 2022

[FIXED] How to pass the correct project path to bitbucket pipeline?

 September 27, 2022     amazon-web-services, aws-lambda, bitbucket, bitbucket-pipelines, continuous-deployment     No comments   

Issue

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


Solution

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


Answered By - Mr-IDE
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing