Answers: <p>The git hooks approach could probably work fine for lone developers. But when multiple developers work on the same project it doesn't work so well, especially in large scale projects.</p>
  
  <p>Several reasons:</p>
  
  <ul>
  <li>the git hooks are local to your copy of the repository, there is no check for consistency across all developers. Anyone can "adjust" their hook script as they see fit, or even forget to get them set up (they're not automatically installed when cloning git repositories for example). A CI platform will consistently run the same scripts for all changes.</li>
  <li>the verifications performed are typically done on the developer's computer, so you're right into the typical "it worked for me" case. Again - consistency: a CI platform will perform the same verifications, in the same context, on a pool of resources much easier to keep consistent than developers' environments</li>
  <li>the verifications performed by a developer are fundamentally silo'd, performed in isolation, on the local snapshot of the repository branch, <em>before</em> the changeset is actually integrated into the branch - they do not take into account the changes from the other developers which can happen at any time. Results obtained that way could be significantly misleading, see <a href="https://devops.stackexchange.com/questions/398/how-can-successfully-pre-verified-changes-cause-regressions-which-should-have-be/512#512">How can successfully pre-verified changes cause regressions which should have been caught?</a>. CI platforms focus on the repository branch itself, checking how a particular changeset performs on that branch at that particular moment, with all other changesets already taken into account, reflecting the actual branch integration status.</li>
  <li>(in larger projects) a CI tool can perform verifications which are impractical for the individual developers. For example multi-platform build lasting hours and requiring high performance build machines well above the typical developer laptop. The centralized verifications performed by a CI platform can be much more resource frugal than when performed by each individual developer.</li>
  </ul>
  
  <p>Side note: not all projects benefit from the developer ability to spin up on demand a production-like environment/clone server ;) But even if possible, most of the above reasons still stand</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-06-28T09:22:00.860Z
Answers: What about server-side hooks?
Answers: rkta
Answers: CC BY-SA 4.0
Answers: 2019-06-28T11:08:22.817Z
Answers: Server-side hooks should be OK, forgot about that. Functionally those make your git server the (custom) CI platform ;) You only need to care about scaling it to be able to handle the extra load associated with the verifications.
Answers: Dan Cornilescu
Answers: CC BY-SA 4.0
Answers: 2019-06-23T04:08:22.603Z
Answers: 2019-06-23T04:08:22.603Z
Answers: Dan Cornilescu
Body: <p>Newbie to devops here and apologies this is probably a stupid question, but, what is the point of CI platforms? It seems to me that just by using git hooks I can automatically run all my unit tests before a commit and block the commit if needed. If I need to run tests in a production clone environment (I don't, but for argument sake), then I should be able to do this by spinning up a clone server and using git server hooks no? It's just that every article I'm reading on CI seems to imply that a CI platform is necessary. But so far nothing has said why. What <em>essential</em> component of CI can I not get unless I use Travis/Circle/Jenkins or whatever?</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-02-26T01:14:03.750Z
Comments: See https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/49994976
Comments: tkruse
Tags: <continuous-integration><git-hooks>
Title: CI platforms versus simple git hooks
UserDisplayName: Neil
ThreadText: # CI platforms versus simple git hooks
  
  (Asked by: username_0 on 2019-06-22)
  
  Newbie to devops here and apologies this is probably a stupid question, but, what is the point of CI platforms? It seems to me that just by using git hooks I can automatically run all my unit tests before a commit and block the commit if needed. If I need to run tests in a production clone environment (I don't, but for argument sake), then I should be able to do this by spinning up a clone server and using git server hooks no? It's just that every article I'm reading on CI seems to imply that a CI platform is necessary. But so far nothing has said why. What *essential* component of CI can I not get unless I use Travis/Circle/Jenkins or whatever?
  
  **Tags:** continuous-integration, git-hooks
  
  > **Comments:**
  > **username_1**: See https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/49994976  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-06-23. Score: 3 | Accepted answer
  
  The git hooks approach could probably work fine for lone developers. But when multiple developers work on the same project it doesn't work so well, especially in large scale projects.
  
  Several reasons:
  
  * the git hooks are local to your copy of the repository, there is no check for consistency across all developers. Anyone can "adjust" their hook script as they see fit, or even forget to get them set up (they're not automatically installed when cloning git repositories for example). A CI platform will consistently run the same scripts for all changes.
  * the verifications performed are typically done on the developer's computer, so you're right into the typical "it worked for me" case. Again - consistency: a CI platform will perform the same verifications, in the same context, on a pool of resources much easier to keep consistent than developers' environments
  * the verifications performed by a developer are fundamentally silo'd, performed in isolation, on the local snapshot of the repository branch, *before* the changeset is actually integrated into the branch - they do not take into account the changes from the other developers which can happen at any time. Results obtained that way could be significantly misleading, see [How can successfully pre-verified changes cause regressions which should have been caught?](https://devops.stackexchange.com/questions/398/how-can-successfully-pre-verified-changes-cause-regressions-which-should-have-be/512#512). CI platforms focus on the repository branch itself, checking how a particular changeset performs on that branch at that particular moment, with all other changesets already taken into account, reflecting the actual branch integration status.
  * (in larger projects) a CI tool can perform verifications which are impractical for the individual developers. For example multi-platform build lasting hours and requiring high performance build machines well above the typical developer laptop. The centralized verifications performed by a CI platform can be much more resource frugal than when performed by each individual developer.
  
  Side note: not all projects benefit from the developer ability to spin up on demand a production-like environment/clone server ;) But even if possible, most of the above reasons still stand
  
  > **Comments:**
  > **username_3**: What about server-side hooks?  
  > **username_2**: Server-side hooks should be OK, forgot about that. Functionally those make your git server the (custom) CI platform ;) You only need to care about scaling it to be able to handle the extra load associated with the verifications.  
  
  ---
  
  