Cookbook Versioning


I’m having a tough time coming up with a way to version chef cookbooks that
makes sense across multiple use cases. I’ve been going around in circles
with this for, well quite honestly, years now.

We originally used Thor ScmVersion but that caused issues when a developer
and Jenkins both tried to bump a cookbook version. I think it was because
each had their local git copies and when git was pushed upstream it caused
a conflict of some sort.

I tried using the knife sport plugin. The issue with that is if jenkins
calls knife spork and that increases the version number in the VERSION
file, that VERSION file needs to be committed back to git. if your building
your cookbook on a git commit, then jenkins builds it again, and again and
again. You get the idea. If you don’t commit the VERSION file back to git,
well then if a developer tries to work with the cookbook their VERSION is
out of sync.

I also tried just having Jenkins write the build number to the VERSION file
and have metadata.rb source from that. That’s fine if only Jenkins ever
needs to test and upload the cookbook. However, if a developer also needs
to work with the cookbook and upload it to say a chef supermarket server
where cookbooks that depend on that can get it from, he is again out of
sync with Jenkins.

How are people solving this issue? It’s never talked about. How about a
script that polls an AWS DynamoDB table and using the cookbook name as a
key, keeps a counter. Each time it’s called it returns the number and bumps
it by one. It wouldn’t matter where it was called from in this case, either
from a developer, Jenkins, or anywhere else.



Hi Doug,

We check our cookbooks into SVN and our Jenkins jobs poll for SCM for changes.

Before the build takes place Jenkins runs a shell script that will update the metadata.rb with a new version number, the build will then run lint checks, ChefSpec and test kitchen runs.

On green build the metadata.rb file gets checked in under the Jenkins CI user, the build is not recursive because we have applied rules to the Poll SCM to ignore any check ins under the Jenkins CI user.

Hope this helps.


How do you configure Jenkins to ignore commits from the Jenkins user?

Nathan Clemons

DevOps Engineer

Moxie Cloud Services (MCS)

O +1.425.467.5075

M +1.360.861.6291


W www.gomoxie.com


For subversion modules there is an advanced button that allows us to add exclusions such as folders to ignore, users, commit messages, not sure if those facilities are available with other SCM modules in Jenkins.We ignore anything checked in as the Jenkins CI user.