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 apackage.json
is found. - Does a
grunt build
if aGruntfile.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.