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

.sh script is not executing

Dusanjudista
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!
July 22, 2024

I'm trying to run my backend app on ec2 instance with ssh-run pipe.

Pipeline is executing successfully but 'run_app.sh' has never been executed.

Here is my yml definition:

 

 

image: atlassian/default-image:3

pipelines:
  branches:
    development:
      - step:
          name: "Build and push to Development environment"
          deployment: Development
          script:
            - envsubst < run_app.sh > run_app.sh
            - pipe: atlassian/ssh-run:0.8.0
              variables:
                SSH_USER: 'ec2-user'
                SERVER: $HOST_SERVER_IP
                SSH_KEY: $AWS_EC2_SSH_KEY
                MODE: 'script'
                COMMAND: 'run_app.sh'
                ENV_VARS: >-
                  AWS_ECR_HOST=${AWS_ECR_HOST}
                  AWS_ECR_IMAGE_NAME=${AWS_ECR_IMAGE_NAME}
                  ENVIRONMENT=${ENVIRONMENT};
                  MONGO_URI=${MONGO_URI};
                  FRONTEND_CORE_BASE_URL=${FRONTEND_CORE_BASE_URL};
                  BACKEND_CORE_BASE_URL=${BACKEND_CORE_BASE_URL};

          services:
            - docker

My 
run_app.sh looks like this:


 

#!/bin/bash

echo "Logging to ECR"
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ECR_HOST
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -aq)

echo "Pulling the latest image"
docker pull $AWS_ECR_HOST/$AWS_ECR_IMAGE_NAME:latest

echo "Running the container"
docker container run -d --publish 80:80 \
--name $AWS_ECR_IMAGE_NAME \n
-e ENVIRONMENT=$ENVIRONMENT \n
-e MONGO_URI=$MONGO_URI \n
-e FRONTEND_CORE_BASE_URL=$FRONTEND_CORE_BASE_URL \n
-e BACKEND_CORE_BASE_URL=$BACKEND_CORE_BASE_URL \n
$AWS_ECR_HOST/architect_core_api_dev

But nothing happens.
In logs I have following logs:


 

Status: Downloaded newer image for bitbucketpipelines/ssh-run:0.8.0
INFO: Executing the pipe...
INFO: Using passed SSH_KEY
INFO: Executing script run_app.sh on (hiddenIP).compute-1.amazonaws.com
ssh -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22 ec2-user@(hiddenIP).compute-1.amazonaws.com bash -s
68
✔ Execution finished.

 

 

0 answers

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