Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket pipelines node server run pm2 issues

matt_baker February 18, 2019

hi, 

below is my package.json script section

"test": "cd ./app/ && mocha --timeout 15000",

"build": "cd ./app && pm2 start app.js",

and below is my bitbucket-pipelines.yml file 

image: node:10.15.1
pipelines: default:

- step: caches: - node

script: # Modify the commands below to build your repository.

- yarn

- yarn build

- yarn test

 my pm2 has successfully configured on bitbucket pipelines

pm2 working.png

and this is below  test fail which works seamlessly on my local machine with pm2   :

 

yarn.png

 

 

can we investigate on same and provide with solution on same .

how do i check whether my server is running or not and proceed with other end to end features testing like login mechanism 

1 answer

0 votes
Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 16, 2019

@matt_baker its been a while since this was posted. Did you manage to get pm2 working? Make sure that the command to start your app via pm2 and the tests happen within the same step.

 

I tried running an extremely minimal express.js app with pm2, and didn't run into any issues:

 

bitbucket-pipelines.yml

image: node:8.15.1-jessie

pipelines:
default:
- step:
script:
- npm install -g pm2
- npm install
- pm2 start server.js
- curl http://localhost:3000

 

server.js

const express = require('express');
const app = express();

app.get('/', (req, res) => {
res.send("Hello World!");
});

const port = 3000;
const server = app.listen(port, () => {
console.log(`Listening on http://localhost:${port}`);
});

 package.json

{
"name": "nodejs-pm2-express",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@bitbucket.org/ggatus/nodejs-pm2-express.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"homepage": "https://bitbucket.org/ggatus/nodejs-pm2-express#readme",
"dependencies": {
"express": "^4.16.4"
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events