Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Run a bash command on EC2 only with pipeline

I already have setup EC2 server and have a file with commands listed to deploy the application in EC2 server.

The bash script does the following steps.

1. Pull the latest code from the master branch

2. Run migrations

3. Restart the server

The pipeline documentation states to configure an S3 bucket and upload the zip file for deployment. It is not getting clear from where this zip file will come and how to upload to S3 in each cycle.


In my case, I only want to run the script each time pipeline is run which will further handle the deployment as specified in the script.


How can I configure the pipeline to run the bash command only by SSHing to the EC2 server? Do I still need to configure S3 Bucket?

2 answers

1 vote

It looks like this pipe might do what you need It was designed specifically for running shell commands or scripts on a remote server. Your pipe configuration might look like this:

  - pipe: atlassian/ssh-run:0.1.1
      SSH_USER: 'ec2-user' # or whatever the username is
      SERVER: '' # your server host 
      COMMAND: 'bash'

 Hope that helps! Cheers

As mentioned in the documentation, you need S3 Bucket if you are using inbuilt `AWS Code Deployment` service in your YAML file.

If you haven't configured anything for AWS Code Deployment, the forget about what documentation says.

The zip file you are talking about is comming from when you build application. Like production Built or something. Say for example if your using angular, you will run `ng build` to build your client for production and it will create files in the `dist` folder of your project. Then after that you have to zip the contents and send it to your server using `AWS Code Deploy` bitbucket service.

Tell me this, where do you want to run this sheel script ``? On your server after all the steps finished?

If that is the case, i will create a very simple restapi client and i run it in my server. This server will have few endpoints like ``

Basically when you hit this api, what it will do is, it will trigger the shell script.

And in YAML after finishing all the steps, i trigger that API using `curl`. 


This is one way, but the best solution is to use `AWS Code Deploy` in bitbucket YAML.

Reference for using AWS Deploy:

Good tutorial for Deploying to AWS using Pipeline:

In my case, I do not have to build the application. I just need to pull the master branch to the EC2 server and run a few commands. That's what that script is doing.


It is running below commands

git pull origin master

pip migrate


Since I'm not building and don't need to move files to the server, do I still need S3? 


The is already on the server at the root level. I just have to SSH and run that script using


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

777 views 15 10
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you