Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build artifacts over ssh jenkins - PHP

Copy only the changed file in bitbucket to the development server , using send build artifacts over ssh jenkins - PHP

HI i am using jenkins and bitbucket , when ever my files changed in bitbucket my jenkins build runs , so now i want to send the chaned file from bitbucket to my development server .

I am using a PHP applicatioin so i just want to copy the changed file .

i checked with this Publish Over SSH in jenkins . and i am not sure what to do exactly

i have few questions with this plugin

  1. I dont understand to set the parameters

enter image description here

this Source files means a lot of files i think , i want to SSH only the changes file . :(

  1. and the remote directory i dont understand also . in my development server my project is inside /var/www/ so i think build=$BUILD_NUMBER should be /var/www/projrct_name :(

I only wat to copy my changed files in bitbucket to the correct locatiion in my developemnt server , can i do it with this plugin, thank you very much

like image 500
Kanishka Panamaldeniya Avatar asked Nov 10 '22 01:11

Kanishka Panamaldeniya


1 Answers

Actually I didn't use any plugin to deploy to dev. You code a bash script that after build, jenkins user ssh to dev server, then cd to project dir, and git pulls latest changes. And then I run some standard commands to prepare the project, like clearing caches, installing dependencies etc. This article helped me a lot.

Check this article http://code.tutsplus.com/tutorials/setting-up-continuous-integration-continuous-deployment-with-jenkins--cms-21511, the article is for nodejs app but the idea is the same

Here is my deploy script, its for my Laravel app.

#!/bin/sh
ssh [email protected] <<EOF
  cd /var/www/projectdir/
  git pull origin master
  composer install --no-dev -o
  php artisan cache:clear
  php artisan view:clear
  php artisan config:clear
  php artisan route:clear
  php artisan optimize --force
  npm install --production
exit
EOF
like image 198
midan888 Avatar answered Nov 12 '22 13:11

midan888