# Syncing Chef Server with external Git Repo

**URL:** <https://discourse.chef.io/t/syncing-chef-server-with-external-git-repo/9748>\
**Category:** Chef Infra (archive)\
**Created:** [October 21, 2016, 7:24pm UTC](https://discourse.chef.io/t/syncing-chef-server-with-external-git-repo/9748 "2016-10-21T19:24:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![spuder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/spuder/32/1382_2.png) [@spuder](https://discourse.chef.io/u/spuder)\
**Post date:** [October 23, 2016, 2:18am UTC](https://discourse.chef.io/t/syncing-chef-server-with-external-git-repo/9748/3 "2016-10-23T02:18:46Z")

</div>

Here is an example where the chef key file is stored on a ci server, and each cookbook has a `.berkshelf` directory that contains a json file with the config of which chef servers to upload to.

Assuming you are using something like jenkins, team city, gitlab -ci that integrates with your version git server. Te following script would be configured to only run on merge to master, or every time a git tag is created.

```
- rm -f Berksfile.lock
- echo "$LAB_CHEF_KEY" > "/foobar/private-key.pem"
- berks install --config=.berkshelf/foo.json
- berks upload --config=.berkshelf/foo.json
- rm /foobar/private-key.pem

```

Inside the cookbook in .berkshelf/foo.json

```
{
  "chef": {
    "chef_server_url": "https://chef.example.com/organizations/foobar",
    "client_key": "/foobar/private-key.pem",
    "node_name": "foobar"
  },
  "ssl": {
    "verify": true
  }
}

```

You can also look into facebooks grocery delivery

> **[facebook/grocery-delivery](https://github.com/facebook/grocery-delivery)**
>
> grocery-delivery - The Grocery Delivery utility for managing cookbook uploads to distributed Chef backends.

---

_[View the full topic](https://discourse.chef.io/t/syncing-chef-server-with-external-git-repo/9748)._
