# This is the first build step for a cookbook repo update which is # triggered by a GitHub callback to Jenkins on commit # Reset the workspace, we don't want the git checkout of $JOB_NAME cd $WORKSPACE/.. rm -rf workspace mkdir workspace cd workspace # Pull down repo git clone git@github.com:YOUR/chef-repo.git cd repo # Add or update the cookbook if [ ! -d "cookbooks/${JOB_NAME}" ]; then git submodule add $GIT_URL cookbooks/$JOB_NAME git submodule init cookbooks/$JOB_NAME git commit -m "Adding cookbook ${JOB_NAME}" .gitmodules cookbooks/$JOB_NAME else git submodule update --init cookbooks/$JOB_NAME cd cookbooks/$JOB_NAME git pull -f -u origin master cd ../.. git commit -m "Updating cookbook ${JOB_NAME} to ${GIT_COMMIT}" .gitmodules cookbooks/$JOB_NAME fi