Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how can i fail bitbucket pipeline when running deployment code using atlassian/ssh run

Nikhil Singh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2025

when i run pipeline i used atlassian ssh run and i made deploy.sh file but in deploy.sh i start the pm2 if it gets fails i exit the code but still my pipeline does not failed it keep running how to failed it 

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 22, 2025

G'day, @Nikhil Singh 

Welcome to the community!

If I understand correctly, you are deploying your application using the ssh-run pipe and a Bash script. However, when the script attempts to start pm2 and fails, your build continues to run instead of stopping. If this is the case, you may need to explicitly specify an exit command in your script. This will ensure that the script exits with a non-zero exit code when an error occurs, causing the build to fail as expected.

Here's an example

#!/bin/bash
# Start the application with pm2 pm2 start app.js
# Check if the previous command was successful if [ $? -ne 0 ]; then echo "Failed to start the application with pm2." exit 1 # Exit with a non-zero status to indicate failure fi
echo "Application started successfully."

I hope this helps.

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events