Deploy rails app with GoCD and Capistrano simplified log file

Clean work directory   “/var/lib/go-agent/pipelines/ROMUI_DEV_DEPLOY”

Create git artifact    “pipelines/ROMUI_Dev_Deploy/Configuration”

Set GoCD ENV variable

Start to build task    ROMUI_Dev_Deploy/649/dev_deployment/1/ha-deploy-runOnAll-1 on lvsdevromuiapp04-01.us.gspt.net  [/var/lib/go-agent]

    Fetch Artifact from CI    

  • execute task: <fetchartifact pipeline=”ROMUI_CI_Deploy” stage=”ci_deployment” job=”run_tests” srcdir=”romui”/>
  • fetch artifact [romui] from [ROMUI_CI_Deploy/675/ci_deployment/run_tests
  • save artifact to [pipelines/ROMUI_Dev_Deploy]

Fetch Artifact from config repo

     bundle install 

bundle exec cap development_integration deploy target=localhost stack=04 branch=develop

  • Run passenger: running /usr/bin/env which passenger as rails@localhost
  • Run RVM:
  •       running /usr/bin/env [-d~/.rvm] as rails@localhost
  •       command: /usr/local/rvm/bin/rvm   default do ruby –version
  • Check git access:  command: (export GIT_ASKPASS=”bin/echo” GIT_SSH=”/tmp/romui/git-ssh.sh”; /usr/bin/env git ls-remote –heads https://gitlab.gspt.net/romui/romuiweb.git
  • INFO The repository mirror is at /rails/apps/deploy/repo
  • command: /usr/bin/env  ln -s /rails/apps/deploy/shared/vendor/bunlde   /rails/apps/deploy/releases/20160728145958/vendor/bundle
  • command: ln -nfs /rails/apps/config/current/.env   /rails/apps/deploy/releases/20160728145958/.env
  • Run ‘rake db:migrate’
  •      command: cd /rails/apps/deploy/releases/20160728145958 && (export RAILS_ENV=”development_integration”; /usr/local/rvm/bin/rvm    default to bundle exec rake db:migrate)
  • Restart app
  •      running /usr/bin/env passenger_config restart_app /rails/apps/deploy –ignore -app-not-running as rails@localhost
  •      command: cd /rails/apps/deploy/releases/20160728145958 && /usr/bin/env passenger-config restart-app /rails/apps/deploy –ignore-app-not-running
  •       restarting /rails/apps/deploy/current
  • Clean up
  •     INFO: keeping 5 of 6 deployed releases on localhost
  •     running /usr/local/rvm/bin/rvm    default to bundle exec rake tmp:clear as rails@localhost

 

Advertisements

Capistrano commands

cap deploy:setup

This will SSH to your server and create some directories in the folder you specified with deploy_to, where Capistrano will store your releases, and your shared files (e.g., logs, configs, static assets like updates, etc.). If something goes wrong with permission or SSH access, you’ll see some error messages. Fix these before proceeding so you know you can actually make a connection to your server.

This should setup the following directories(if you’ve specified to install your app in /app_name/):

/app_name/current

/app_name/shared

/app_name/releases

 

The “releases” directory is where copies of all your actual code are stored.

“shared” is a place where you can put common, shared files like logs, static assets, and maybe config files like database.yml.

“current” is simply a symbolic link that points to the current release inside the “releases” directory (capistrano updates this on each deploy)

 

 

cap deploy:check

Check your local environment and your server and try to locate any possible issues.

 

 

cap deploy:update_code

Update application code