Reputation: 2290
I have recently started working with CI using Bitbucket Pipelines. I have managed to connect using my SFTP server, creating API public & private keys and adding them to my server using SSH.
Now, when I run the build it will upload all my files to the correct folder. But I am having a problem that running a package.json command from the script "yarn build" is doing absolutely nothing.. nothing is in the root folder.
What am I missing or doing wrong? Locally everything works just fine same goes for uploading files.
My bitbucket-pipeline.yaml:
# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:10.15.3
pipelines:
branches:
develop:
- step:
name: Lets push the data to the Server.
caches:
- node
script:
- pipe: atlassian/sftp-deploy:0.4.1
variables:
USER: $SFTP_username
PASSWORD: $SFTP_password
SERVER: $SFTP_host
REMOTE_PATH: /var/www/html/pipeline-http/test-website/
DEBUG: 'true'
- step:
name: Build and test website and deploy.
caches:
- node
script:
- yarn install
- yarn test-build
artifacts:
- assets/**
Upvotes: 4
Views: 3783
Reputation: 2068
Your pipelines steps are in wrong order.
Bitbucket pipelines are executed in the cloud which means, you have to build your project first, than copy everything to the server (since it cant really copy and build your project on your server)
For your case, this should be correct solution
branches:
develop:
- step:
name: Build and test website and deploy.
caches:
- node
script:
- yarn install
- yarn test-build
artifacts:
- assets/**
- step:
name: Lets push the data to the Server.
caches:
- node
script:
- pipe: atlassian/sftp-deploy:0.4.1
variables:
USER: $SFTP_username
PASSWORD: $SFTP_password
SERVER: $SFTP_host
REMOTE_PATH: /var/www/html/pipeline-http/test-website/
DEBUG: 'true'
Upvotes: 2