What are Jenkins best practices with building with Grunt and deploying with Capistrano?
Asked Answered
N

1

8

I'm currently setting up a build server at our office and I was wondering what's best practice for this. I know each situation asks for a different approach and there are a million ways to achieve the same goal, but since I'm a newcomer to Jenkins and the concept of build servers in general, I was wondering if I'm doing this 'right'.

Our company focusses on building websites for various clients with various platforms like WordPress or Magento. I now have the following setup:

We push our changes to a master or staging-branch in Git. Jenkins polls these branches and does the following when a change is detected:

  • Pull the repository from Git (master in this example)
  • Checkout a branch called build-master
  • Resets this branch to origin/master
  • Does a npm install if a package.json is found.
  • Does a grunt build if a Gruntfile.js is found.
  • (here is room for other stuff like phpunit or casperJS tests)
  • Commits changes and pushes it back to origin/build-master.
  • Executes a cap build-master deploy to let Capistrano handle the deployment on the remote server.

Now I was wondering if this is a 'correct' way of using a build server. I run into some logical problems. Like:

Vendor-software for example. When I have various JS libraries with Bower for example (which are located in a git-ignored js/vendor-folder), I can concatenate and uglify them into a minified JS file so they git committed into the build-master-repository (for Capistrano). But when I have PHP-libraries (with Composer for example) I'm not sure how to deal with this. These are located in a git-ignored php/vendor-folder, but they need to be included in the build-master-branch so the get deployed on the live-server. Currently I'm doing this by adding a .gitignore.build to my repository, which includes the php/vendor-folder, and overwrite the existing .gitignore with this one prior before committing and pushing to origin/build-master.

And/or:

Compiled files. When I don't want to include some files (like CSS-files generated from SASS for example), I put these in the .gitignore. But again, when Capistrano is going to deploy it, I want the compiled, concatinated and minified CSS file to be in my repository, otherwise it's not put on my production server.

Can anyone tell me if I'm building and deploying in the way it 'should' be? Or am I totally over-complicating it here for me? I'm really interested in how people with more experience with this are utilizing Jenkins, Grunt, Bower, Composer, Capistrano, etc. in their build process.

Ninebark answered 26/6, 2014 at 13:17 Comment(1)
One thing I've wondered about is committing binaries. Since you do that, I wonder if you work to ensure a dev's checkout stays slim, without the binaries?Recourse
P
0


I'm looking for the exact same response. I am in the same situation, and wondering how this could be done with the best start up configuration.
Since you're wondering about the use of grunt for deployment, there is this tutorial that can be useful for your, i hope this will give starting ideas: https://weluse.de/blog/continuous-deployment-with-yeoman-and-jenkins.html
Also, i am interested if you have any feedback from your current project.

Petticoat answered 18/8, 2014 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.