If you need to add automatic build numbers on the Wercker platform, here are a few gotchas.
- The hash:
git describe --always --dirty
. This works just fine, but it always reports as dirty. You might want to filter that out. - The branch:
process.env.WERCKER_GIT_BRANCH
. You cannot get this from Git because Wercker checks out a specific commit, independent of the current branch. - The build number:
git rev-list --count HEAD
. This only works if you rungit fetch --unshallow
beforehand. This is because Wercker uses a shallow checkout to save bandwidth, thus Git doesn't know about all revisions and reports the wrong build number if you leave this out. A caveat here is that you cannot use the SSH key that Wercker used for fetching the code, so the easiest way is to convert the remote origin to http withgit remote set-url origin
.