1

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?

1
  • Are you using rvm on your machine? Commented Jul 25, 2016 at 15:52

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.