-1

I hope you are doing well! I'm facing a problem when trying to deploy using Bitbucket pipeline.

The project is a React project at version 18.2.0 and its files are in the frontend folder.

bitbucket-pipelines.yml

image: atlassian/default-image:3

# Workflow Configuration
pipelines:
  branches:
    staging:
      - parallel:
        - step:
            name: Build and Test
            script:
              - npm install --prefix ./frontend/ --legacy-peer-deps
              - npm audit fix --force --prefix ./frontend/
              - npm audit fix --force --prefix ./frontend/
              - npm run build --prefix ./frontend/
            artifacts:
              - ./frontend/build/**
      - step:
          name: Deploy to Staging
          deployment: Staging
          script:
            - pipe: atlassian/scp-deploy:0.3.3
              variables:
                USER: $USER
                SERVER: $SERVER
                REMOTE_PATH: '/var/www/html'
                LOCAL_PATH: './'

The error that I am not able to solve is related to the LOCAL_PATH folder.

I tried some variations:

./frontend/build/*

  • No such file or directory

./build/*

  • No such file or directory

./

  • error: unexpected filename: .

Thanks in advance for any help

  • I'm not here to put up with rude responses like yours. The title of the question was exactly what was happening, trying to deploy in bitbucket. I searched for hours before posting and in no time I came across your duplicate answer. Unfortunately I can't delete this post, because that was my will now so I don't have to read comments like yours –  Nov 21 '22 at 16:26
  • Didn't mean to be rude, sorry it came that way. Also you should 1) chill 2) read this guidelines https://stackoverflow.com/help/how-to-ask . You surely understand this website aims at providing a general Q&A catalog that is useful for everyone future-wise, not only solving your particular current problem. Hence the pursue of question quality and uniqueness. If you recall that linked duplicate but were not able to relate to it I invite you to comment on it and suggest any improvement you feel will make it easier to find and understand for future readers. Cheers. – N1ngu Nov 21 '22 at 16:41
  • "You must do this or you must do that". This is why new people are afraid to create a stackoverflow account, your duplicate post answer was titled "perfect", however I couldn't find it. Sometimes people are just looking for answers to things they are trying to do and not looking for a perfect title to find a solution to their problem –  Nov 21 '22 at 17:42
  • Still duplicate for https://stackoverflow.com/q/56196454/11715259 – N1ngu Nov 22 '22 at 19:46

1 Answers1

1

TL;DR

In your build step, use:

artifacts:
  - frontend/build/**

In the scp deploy, use the same value for the LOCAL_PATH variable:

variables:
  ...
  LOCAL_PATH: 'frontend/build/*'

Explanation

The reason why the usual syntax does not work is that Bitbucket uses glob patterns for its paths. For example from the documentation on artifacts:

You can use glob patterns to define artifacts. Glob patterns that start with a * will need to be put in quotes.
Note: As these are glob patterns, path segments “.” and “..” won’t work. Use paths relative to the build directory.

That means you don't want or need the leading ./. Check the Bitbucket documentation on scp deployment for a concrete example matching your case.

thorndeux
  • 307
  • 2
  • 9