sujan kumar ghosh
sujan kumar ghosh

Reputation: 11

Deploy issue with aws codedeploy & ubuntu on ec2

I am deploying a ruby code using AWS CodeDeplo plugin for jenkins. Jenkins is triggering deployment and the deployment is successful. Successful i meant to say copying files to server is a success.

The server is runnung on ubuntu 14.04 with Ruby2.3.1

Post deployment, there are .sh files to be executed. These details are maintained via appspec.yml file. It is mentioned in the appspec.yml file to execute as user:devops

The .sh files are getting executed, but the result us not successful.

The issues are as below: 1. The commands in the .sh file includes gem installations. 2. The execution of execution is resulting in error as it is always referring to ruby 1.9.3 but not 2.3.1

We anlysed the directories / code deployment log file & found below: 1. The codedeploy agent directory is owned by an user with 4 digit numeric value e.g.3456 2. When printing the ruby-v it is printing as 1.9.3, even from terminal it always shows as 2.3.1 3. The log shows an error that some gem installation failed as there us no permission to write in gems/1.9.1 directory

When we execute the .sh file from terminal the execution is always successful.

Can some focus on where i have done wrong?

Upvotes: 1

Views: 409

Answers (1)

Chris
Chris

Reputation: 3865

CodeDeploy agent doesn't have shell env.

Since I am using rvm on the machine where code is deployed and on top of my .sh files I put

#!/bin/bash
source /etc/profile.d/rvm.sh
rvm use 2.3.0 
#rest of your commands

This works fine for me.

Upvotes: 1

Related Questions